I am having trouble getting my java program to read any text files.
public static void main(String[] args) throws java.io.IOException {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
try {
long base = Long.parseLong(args[0]);
String input = br.readLine(); //read first line till the end of file
long list = Long.parseLong(input);
convertBase(base, list);
}
finally {
br.close();
}
}
The program works when I manually type the values into the command line, but when I try to use a text file it throws exceptions:
Exception in thread "main" java.lang.NumberFormatException: For input string: "baseconverion.txt"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Long.parseLong(Long.java:589)
at java.lang.Long.parseLong(Long.java:631)
at FromDecimal.main(FromDecimal.java:46)
Not sure what I am doing wrong/missing.