• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

TEMP file question

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
did you try to cast your InputStream in as FileInputStream before calling the close method ?

Fred
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic