{"id":5,"date":"2005-09-17T15:10:29","date_gmt":"2005-09-17T20:10:29","guid":{"rendered":"http:\/\/www.juixe.com\/techknow\/?p=5"},"modified":"2005-09-17T15:10:29","modified_gmt":"2005-09-17T20:10:29","slug":"delete-temporary-files-on-exit","status":"publish","type":"post","link":"http:\/\/juixe.com\/techknow\/index.php\/2005\/09\/17\/delete-temporary-files-on-exit\/","title":{"rendered":"Delete Temporary Files on Exit"},"content":{"rendered":"<p>Sometimes your application requires holding data in a temporary file.  I&#8217;ve had to do this when printing a PDF file.  The following bit of code demonstrates how to create a temporary file and delete said file when the program terminates.<\/p>\n<pre>\nFile temp = File.createTempFile(&quot;SomePrefix&quot;, &quot;.pdf&quot;);\ntemp.deleteOnExit();\n<\/pre>\n<p>The file is created in the system\u00c3\u00a2\u00e2\u201a\u00ac\u00e2\u201e\u00a2s temp directory, see the Java java.io.tmpdir property.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes your application requires holding data in a temporary file. I&#8217;ve had to do this when printing a PDF file. The following bit of code demonstrates how to create a temporary file and delete said file when the program terminates. File temp = File.createTempFile(&quot;SomePrefix&quot;, &quot;.pdf&quot;); temp.deleteOnExit(); The file is created in the system\u00c3\u00a2\u00e2\u201a\u00ac\u00e2\u201e\u00a2s temp directory, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":""},"categories":[15,3],"tags":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p902K-5","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/5"}],"collection":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/comments?post=5"}],"version-history":[{"count":0,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/posts\/5\/revisions"}],"wp:attachment":[{"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/media?parent=5"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/categories?post=5"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/juixe.com\/techknow\/index.php\/wp-json\/wp\/v2\/tags?post=5"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}