ImageIO.write success on one pc, failure on another...

T

tiewknvc9

hi!

Im trying to have my java desktop <i> application </i> write images out
to a file. This works successfully on numerous PCs... and fails on
numerous PCs.

The odd thing is that it is the same exact code, and the same exact
virtual machine! I wish I could develop on one of the machines that it
is failing on, but I can't.

my code is...

iImageCount = 1; //example
File filImg = new File("/temp/myImage" + iImageCount + ".png");
ImageIO.write(renImage, "png", filImg);

the error that comes up is a fileNotFoundException! I tried to add in
filImg.createNewImage(), but that causes problems on the computers that
it is currently working on.

any clue as to where I should begin to figure out an answer?

Thanks!
 
Y

Ye Dafeng

tiewknvc9 said:
hi!

Im trying to have my java desktop <i> application </i> write images out
to a file. This works successfully on numerous PCs... and fails on
numerous PCs.

The odd thing is that it is the same exact code, and the same exact
virtual machine! I wish I could develop on one of the machines that it
is failing on, but I can't.

my code is...

iImageCount = 1; //example
File filImg = new File("/temp/myImage" + iImageCount + ".png");
ImageIO.write(renImage, "png", filImg);

the error that comes up is a fileNotFoundException! I tried to add in
filImg.createNewImage(), but that causes problems on the computers that
it is currently working on.

any clue as to where I should begin to figure out an answer?

Thanks!
I think you should use the File.seperator, because in different os, the
file separator is different
 
M

Missaka Wijekoon

tiewknvc9 said:
hi!

Im trying to have my java desktop <i> application </i> write images out
to a file. This works successfully on numerous PCs... and fails on
numerous PCs.

The odd thing is that it is the same exact code, and the same exact
virtual machine! I wish I could develop on one of the machines that it
is failing on, but I can't.

my code is...

iImageCount = 1; //example
File filImg = new File("/temp/myImage" + iImageCount + ".png");
ImageIO.write(renImage, "png", filImg);

the error that comes up is a fileNotFoundException! I tried to add in
filImg.createNewImage(), but that causes problems on the computers that
it is currently working on.

any clue as to where I should begin to figure out an answer?

Thanks!
Is it possible that "/temp" does not exist on the machines that fail?
Or perhaps you lack permission to write to that directory.

-Missaka
 
A

Andrew Thompson

Ye said:
tiewknvc9 wrote: ....

Usenet readers do not understand HTML, whereas
'usenet format' is more like /italic/ or *bold*.
....
This code is very haphazzard, it is no surprise to me
that it fails.
....
I think you should use the File.seperator,

Good call, that is also available as
System.getProperty("file.separator"),
...also look into..
"java.io.tmpdir"

And file constructor File(File parent, String name),
which allows you to ignore file.separator, and..

...oh, yeah. What Missaka was saying, check each
dir/file along the way,
- does it exit?
- is it writable?

Andrew T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top