This example code shows how to read the content of a textfile or any other file.
You can either print every line, or put everything inside a string and print it in the end:
import java.io.*;
public class MainClass {
public MainClass() {
}
public static void main(String[] args) throws FileNotFoundException, IOException
{
BufferedReader test = new BufferedReader(new FileReader("test.txt"));
String currentLine = "";
String theWholeDocument = "";
while ((currentLine = test.readLine()) != null)
{
theWholeDocument += currentLine+"n";
System.out.println(currentLine);
}
// System.out.println(theWholeDocument);
}
}
Here is a fast and simple tutorial for opening and reading files with JAVA. Code example inside!
http://www.devdaily.com/java/edu/pj/pj010017/index.shtml