adsense


Showing posts with label JAVA EXAMPLES CREATE A TEMPORARY FILE. Show all posts
Showing posts with label JAVA EXAMPLES CREATE A TEMPORARY FILE. Show all posts

Tuesday, 27 October 2015

JAVA EXAMPLES CREATE A TEMPORARY FILE PAGE 97

COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button



JAVA EXAMPLES CREATE A TEMPORARY FILE



Java Examples - Create a temporary File


Problem Description:
How to create a temporary file?
Solution:
This example shows how to create a temporary file using createTempFile() method of File class.
import java.io.*;

public class Main {
   public static void main(String[] args) 
   throws Exception {
      File temp = File.createTempFile
      ("pattern", ".suffix");
      temp.deleteOnExit();
      BufferedWriter out = new BufferedWriter
      (new FileWriter(temp));
      out.write("aString");
      System.out.println("temporary file created:");
      out.close();
   }
}
Result:
The above code sample will produce the following result.
temporary file created: