Creating file using File handling Technique

import java.io.FileOutputStream;
public class FileHandling {
public static void main(String[] args) {
try {
FileOutputStream f= new FileOutputStream("Data.txt");
String i = "File written by using File Output Stream Class";
byte b []=i.getBytes();
f.write(b);
f.close();
} catch (Exception e) {
System.out.println("exception");
}
}
}
/**This is a program for creating any type of file using file handling technique.
*
* we make an object of file handling stream class where we specify which type of file we wish to create and
* we create that using their .extention name suffixed with the filename.
* here data.txt so a text file will be created.You may add extension of your wish.
* Don't forget to import FileOutputStream.
*/

No comments:

Post a Comment