Skip to content

Instantly share code, notes, and snippets.

@avwave
Forked from anonymous/gist:3727679
Created September 15, 2012 13:07
Show Gist options
  • Save avwave/3727760 to your computer and use it in GitHub Desktop.
Save avwave/3727760 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) {
//read until line begins with frames
if (!strLine.startsWith("FRAME")){
//put lines in inner array
innere.add(strLine);
strLine = br.readLine();
} else {
list.add(innere);
}
}
Collections.reverse(list);
System.out.println();
doLoop(list);
in.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
void doLoop(ArrayList<ArrayList>list) {
for(ArrayList<String>subList:list) {
for(String str:subList) {
System.out.println("str");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment