Java I/O File code; how to read/write file
I've been reading from Lesson: Basic I/O (The Java™ Tutorials > Essential Classes) but I don't understand the jargon very well without examples.
What I'm trying to figure out how to do is read a file.
I think this code will work for that: File inFile = new File(filelocation);
The file should have texts which I'm trying to reorganize. On SQL, I would import the database, and parse out the information with case statements. I want to do the same with Java but I'm very unfamiliar with the code of Java.
Can you give me an online source where I can find examples of how to read/edit text within a file?
Re: Java I/O File code; how to read/write file
java.io.File is just a reference to a file, nothing more. To open a file for reading you need an InputStream for bytes or an InputStreamReader for characters. Most Java coders I know would use java.io.BufferedReader's readLine() method for line-at-a-time reading. There's a code fragment which is precisely what you want in the intro to BufferedReader in the API documentation:
BufferedReader (Java Platform SE 6)