Created
August 19, 2013 04:29
-
-
Save vaskaloidis/6265777 to your computer and use it in GitHub Desktop.
Java File Parser
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
package project5; | |
import java.io.*; | |
public class fileParser { | |
public fileParser(String inputFile){ | |
fileName = inputFile; | |
} | |
public String[][] getArray() throws IOException{ | |
FileReader fr = new FileReader(fileName); | |
BufferedReader br = new BufferedReader(fr); | |
int rowCount = 0; | |
while((lineCounter = br.readLine()) != null) { | |
rowCount++; | |
} | |
String[][] data = new String[rowCount][7]; | |
count = 0; | |
while((lineString = br.readLine()) != null) { //To read each file line individually | |
String [] lineArray = lineString.split("-"); | |
for(int x = 0; x < lineArray.length; x++){ | |
data[count][x] = lineArray[x]; | |
} | |
System.out.println(""); | |
count++; | |
} | |
return data; | |
} | |
private static String fileName, lineString, lineCounter; | |
private static int count = 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment