Advertisement
asanchez75

java/bigfiles

Feb 3rd, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1. package fr.inrialpes.exmo.data;
  2.  
  3. import java.io.*;
  4. import java.util.Arrays;
  5.  
  6. import org.apache.commons.lang3.StringUtils;
  7.  
  8. import fr.inrialpes.exmo.data.LinkMatrix;
  9.  
  10. public class RandomAccessFileDemo {
  11.  
  12.    public static void main(String[] args) throws IOException {
  13.       try {
  14.          // create a new RandomAccessFile with filename test
  15.         RandomAccessFile raf = new RandomAccessFile("result.txab", "rw");
  16.         LinkMatrix extendedLinks = LinkMatrix.create();
  17.         while (raf.readLine() != null) {
  18.             //System.out.println(raf.readLine());
  19.             String line = raf.readLine();
  20.             String[] parts = StringUtils.split(line, "\\|");
  21.             extendedLinks.put(parts[0], parts[2], new String[] {parts[0], parts[1], parts[2], parts[3]});
  22.         }
  23.         System.out.println("size = " + extendedLinks.size());
  24.       } catch (NullPointerException ex) {
  25.          ex.printStackTrace();
  26.       }
  27.  
  28.    }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement