Preview:
import java.io.*;

public class FileReaderDemo
{
	public static void main(String[] args)
	{
		try(FileReader fr = new FileReader("FileReaderDemo.java"))
		{
			int c;
			while((c=fr.read())!= -1)
				System.out.print((char)c);
		}
		catch(IOException ie){ ie.printStackTrace(); }
	}
}

import java.io.*;

public class FileWriterDemo
{
	public static void main(String[] args)
	{
		try(FileReader fr = new FileReader("FileWriterDemo.java");
		    FileWriter fw = new FileWriter("Test2.dat");
		)
		{
			int c;
			while((c=fr.read())!= -1)
				fw.write((char)c);
		}
		catch(IOException ie){ ie.printStackTrace(); }
	}
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter