Advertisement
Guest User

luiz

a guest
Jul 25th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. public static List<Registro> getRegistros() throws IOException {
  2.         InputStream is = new FileInputStream("teste.txt");
  3.         InputStreamReader isr = new InputStreamReader(is);
  4.         BufferedReader br = new BufferedReader(isr);
  5.  
  6.         List<Registro> registros = new ArrayList<>();
  7.         String s = br.readLine();
  8.         String subID;
  9.         while (s != null) {
  10.             subID = s.substring(0, s.indexOf(' '));
  11.             String auxID[] = subID.split("_");
  12.             s = s.substring(s.indexOf(' ') + 1, s.length());
  13.             List<String> autores = new ArrayList<>();
  14.             String aux[] = s.split("<>");
  15.             String autoresList[] = aux[0].split(";");
  16.             for (int i = 0; i < autoresList.length; i++) {
  17.                 autores.add(autoresList[i]);
  18.             }
  19.             String titulo = aux.length > 1 ? aux[1] : "";
  20.             String congresso = aux.length > 2 ? aux[2] : "";
  21.             Registro r = new Registro(autores, titulo, congresso, Integer.parseInt(auxID[0]),
  22.                     Integer.parseInt(auxID[1]));
  23.             registros.add(r);
  24.             s = br.readLine();
  25.         }
  26.  
  27.         br.close();
  28.         return registros;
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement