adsense


Showing posts with label JAVA EXAMPLES CREATION OF FILE. Show all posts
Showing posts with label JAVA EXAMPLES CREATION OF FILE. Show all posts

Monday, 26 October 2015

JAVA EXAMPLES CREATION OF FILE PAGE 90

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



JAVA EXAMPLES CREATION OF FILE


Java Examples - Creation of File



Problem Description:
How to create a file in a specified directory ?
Solution:
This example demonstrates how to create a file in a specified directory using File.createTempFile() method of File class.
import java.io.File;

public class Main {
   public static void main(String[] args) 
   throws Exception {
      File file = null;
      File dir = new File("C:/");
      file = File.createTempFile
      ("JavaTemp", ".javatemp", dir);
      System.out.println(file.getPath());
   }
}
Result:
The above code sample will produce the following result.
C:\JavaTemp37056.javatemp