This has been asked countless times but I haven't gotten a solution for it. My code:
import java.util.Scanner;
import java.io.*;
public class Reverse
{
public static void main(String[] args)
{
File myFile = new File(args[0]);
try
{
Scanner input = new Scanner(myFile);
String message = "";
while(input.hasNext())
{
message = input.nextLine() + message;
}
System.out.println(message);
input.close();
}
catch(FileNotFoundException e)
{
System.exit(1);
}
}
}
Details:
Being coded through Eclipse on Mac
Ran on command line using javac Reverse.java then java Reverse.java (edit: java Reverse works)
- This has something to do with classpaths, but I have no clue what I'm supposed to do
I haven't done anything with regards to classpaths so any help is appreciated.
edit: My question now is, how does java -classpath . Reverse work? I don't really understand the -classpath tag and the '.' tag.