Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.regex.*;
- public class ParseTest {
- public static void main(String[] args) throws FileNotFoundException, IOException {
- System.out.println(processFile("Modern-2015-03-28.txt"));
- //readFile("Modern-2015-03-28.txt");
- }
- public static CardPool processFile(String filename)throws FileNotFoundException, IOException {
- FileReader fileReader = new FileReader(filename);
- ArrayList<Card> c = new ArrayList<Card>();
- BufferedReader in = new BufferedReader(fileReader);
- int i = 0;
- while (i < 3500) {
- String s = in.readLine();
- if(s == null)break;
- if(s.matches("(\\w\\d\\d|\\w\\w\\w-\\w)(,? ?(\\w\\d\\d|\\w\\w\\w-\\w)?){0,}")){
- in.readLine();
- String a = in.readLine();
- if(a == null)break;
- c.add(new Card(a));
- i++;
- }
- //System.out.println(s);
- }
- return new CardPool(c);
- }
- public static void readFile(String filename)throws FileNotFoundException, IOException {
- FileReader fileReader = new FileReader(filename);
- BufferedReader in = new BufferedReader(fileReader);
- while (true) {
- String s = in.readLine();
- if(s == null)break;
- System.out.println(s);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement