Preview:
Import java.io.File;
Import java.io.FileNotFoundException;
Import java.io.PrintWriter;
Import java.lang.Integer;
Import java.util.ArrayList;
Import java.util.Scanner;

//Reads a file named "ints-in.txt" containing integers and writes the integers to "ints-out.txt" in reverse order.

Class PrintReverse {
	Public static void main (String[] args) throws FileNotFoundException {
		//Create an ArrayList of Integers
		ArrayList<Integer> list = new ArrayList<>();
		Scanner scanner = new Scanner(new File("ints-in.txt"));
		while(scanner.hasNext()){
			list.add(scanner.nextInt());
		}
		scanner.close();
		
		PrintWriter out = new PrintWriter(new File("ints-out.txt"));
		for (int I = list.size()-1; I >= 0; --i){
			out.println(list.get(i));
		}
		out.close();
	}
}
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