Skip to content

Instantly share code, notes, and snippets.

Created September 15, 2012 12:57
Show Gist options
  • Save anonymous/3727679 to your computer and use it in GitHub Desktop.
Save anonymous/3727679 to your computer and use it in GitHub Desktop.
import java.io.*;
import java.util.Arrays;
import java.util.ArrayList;
class FileRead
{
public static void main(String args[])
{
try{
FileInputStream fstream = new FileInputStream("textfile.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
//2 dimensional ArrayList
ArrayList<ArrayList> list = new ArrayList<ArrayList>();
ArrayList<String> innere = new ArrayList<String>();
//read each line
while ((strLine = br.readLine()) != null) {
//new object
list.add(innere);
//read until line begins with frames
while (strLine!="FRAMES"){
//put lines in inner array
innere.add(strLine);
strLine = br.readLine();
}
}
System.out.println();
in.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment