Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2006

Tip: Looking for answers? Try searching our database.

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

Thread view: 
tiewknvc9 - 15 Nov 2006 04:08 GMT
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!
Ye Dafeng - 15 Nov 2006 05:31 GMT
> hi!
>
[quoted text clipped - 19 lines]
>
> Thanks!

I think you should use the File.seperator, because in different os, the
file separator is different
Andrew Thompson - 15 Nov 2006 08:04 GMT
...
> > Im trying to have my java desktop <i> application </i>

Usenet readers do not understand HTML, whereas
'usenet format' is more like /italic/ or *bold*.
...
> > my code is...
> >
> > iImageCount = 1;  //example
> > File filImg = new File("/temp/myImage" + iImageCount + ".png");
> > ImageIO.write(renImage, "png", filImg);

This code is very haphazzard, it is no surprise to me
that it fails.

> > the error that comes up is a fileNotFoundException!
...
> 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.
Missaka Wijekoon - 15 Nov 2006 07:11 GMT
> hi!
>
[quoted text clipped - 19 lines]
>
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.