Site icon NgDeveloper

Java File Writting example

Program:

[java]
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

public class FileWrite {

public static void main(String[] args) {
String input ="Javadomain.in can provides a programming problem solutions";
byte[] byte_input = input.getBytes();
try {

FileOutputStream fos = new FileOutputStream(new File("D:\\javadomain.txt"));
fos.write(byte_input);
System.out.println("File created and input written in the file successfully");

} catch (IOException e) {
e.printStackTrace();
}
}

}
[/java]

 

 

Thanks for reading this post……………….!!!

Exit mobile version