Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Node{
- String question;
- String answer;
- String date;
- }
- List lista = new ArrayList<Node>();
- public void makeObjects() throws IOException{
- Node n = new Node();
- BufferedReader br = new BufferedReader(
- new FileReader("C:\\Users\\Boki\\FullFrontend\\src\\java\\fullfrontend\\a.txt"));
- String pattern = "Q:(.*)A:(.*)Date:(.*)";
- String line;
- while((line = br.readLine())!=null) {
- //String line = "Q:Sta je ndaj? A: To je dahdjd. Date: 12/12/2012";
- Pattern r = Pattern.compile(pattern);
- Matcher m = r.matcher(line);
- if (m.find( )) {
- n.question = m.group(1);
- n.answer = m.group(2);
- n.date = m.group(3);
- lista.add(n);
- /* System.out.println("Found value: " + m.group(0) );
- System.out.println("Found value: " + m.group(1) );
- System.out.println("Found value: " + m.group(2) );
- System.out.println("Found value: " + m.group(3) );*/
- }else {
- System.out.println("NO MATCH");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement