my dog learned polymorphism*
The moose likes Java in General and the fly likes TEMP file question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "TEMP file question" Watch "TEMP file question" New topic
Author

TEMP file question

Pradeep Kumar T
Greenhorn

Joined: Apr 14, 2007
Posts: 12
Hi all,
In my application, I am using a font resource(TTF file), which i load using

InputStream in = getClass().getResourceAsStream("ARIALUNI.TTF");
Font font = Font.createFont(Font.TRUE_TYPE,in);

Every time, I use this resource, a temp file named "+~JFxxxx.tmp" is created in the TEMP directory. This happens even when the app is deployed as a jar. Can anyone let me know, if this can be avoided or how to remove these temp files when the program terminates.

Thanks in advance
Pradeep
Frederic Henri
Greenhorn

Joined: Mar 29, 2007
Posts: 5
hi Pradeep,

As the javadoc states for createFont method, this method does not close the inputStream.
If you have a close() method that is called when you close your application, you coud close the stream and the temp file should disappear.

Fred
Pradeep Kumar T
Greenhorn

Joined: Apr 14, 2007
Posts: 12
Thanks for the reply. I have already closed the stream using the close method, but according to the javadoc it(InputStream's close()) has no implementation.
Is there any other way for this.
Thanks again.
Frederic Henri
Greenhorn

Joined: Mar 29, 2007
Posts: 5
did you try to cast your InputStream in as FileInputStream before calling the close method ?

Fred
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Er, what?

If the InputStream is a FileInputStream, calling close() will already do FileInputStream.close(). If the InputStream is not a FileInputStream, casting will fail; you can't somehow turn it into a FileInputStream by casting.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: TEMP file question
 
Similar Threads
file read/write
how to change the font-family in XSLT file
Can I use include file in resource bundle properties file?
display Formfile from struts form in session scope
While loops