I need to create a java program that reads a text file line by line, and inserts each line of text into a long. I'm using Buffered Reader, but I can only get it to read the line of text as a String. Is there any way to avoid parsing each line from String to Long?
A Reader only reads in Strings. If the file is a non-text file with binary data, you can read this in with say a (buffered) DataInputStream or if it's a serialized object then a buffered ObjectInputStream. Otherwise if it is text, then you'll likely want to use a Scanner object to read in the text and convert to longs, or use your reader and convert it yourself.
It's a simple enough job to do a Long.valueOf().