-
-
Save avwave/3727760 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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