Java File Writting example

(Last Updated On: August 11, 2016)

Program:

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();
	}
	}

}

 

 

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

171 total views, 5 views today

Leave a Reply

Your email address will not be published. Required fields are marked *