Monday, 15 June 2015

Creating File in java

import java.io.File;
import java.io.IOException;

public class WriteInFile {

public static void main(String[] args) {
// TODO Auto-generated method stub
try {
File f = new File("d:\\newfile.txt");       // path to create file

if (f.createNewFile()){
System.out.println("file created");
}else{
System.out.println("file is their");
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

}

No comments:

Post a Comment