Package java.io

Examples of java.io.BufferedReader


   * @param id
   * @return
   */
  public static String getTextContent(int type, long id){
    String path = getFilePath(type, id);
    BufferedReader br = null;
    StringBuffer text = new StringBuffer();
    try{
      String line_sep = System.getProperty("line.separator");
      if(line_sep==null)
        line_sep = "\r\n";
      br = new BufferedReader(new FileReader(path));
      do{
        String line = br.readLine();
        if(line == null)
          break;
        text.append(line);
        text.append(line_sep);
      }while(true);
      return text.toString();
    }catch(FileNotFoundException e){
    }catch(IOException e){
      log.error("Exception occur when reading " + path, e);
    }finally{
      if(br!=null){
        try{
          br.close();
        }catch(IOException e){}
      }
      text = null;
    }
    return null;
View Full Code Here


        File file = new File(inputFile);
        if(!file.exists()) {
            Assert.fail("file not found: " + inputFile);
        }
        String filename = FileUtils.basename(inputFile);
        BufferedReader reader = new BufferedReader(new FileReader(file));
        runBenchmarkWithZipfDistribution(filename, capacity, round, scanPercentage, scanLength, ReplacementAlgorithm.GClockK, reader);
        IOUtils.closeQuietly(reader);
        reader = new BufferedReader(new FileReader(file));
        runBenchmarkWithZipfDistribution(filename, capacity, round, scanPercentage, scanLength, ReplacementAlgorithm.GClock, reader);
        IOUtils.closeQuietly(reader);
        reader = new BufferedReader(new FileReader(file));
        runBenchmarkWithZipfDistribution(filename, capacity, round, scanPercentage, scanLength, ReplacementAlgorithm.LRU, reader);
        IOUtils.closeQuietly(reader);
    }
View Full Code Here

        System.gc();

        // GClockK
        String filename = FileUtils.basename(inputFile);
        BufferedReader reader = new BufferedReader(new FileReader(file));
        runBenchmarkWithZipfDistribution1(new NoopLock(), filename, threads, capacity, round, scanPercentage, scanLength, ReplacementAlgorithm.GClockK, pageSize, reader);
        IOUtils.closeQuietly(reader);
    }
View Full Code Here

        System.gc();

        // GClock
        String filename = FileUtils.basename(inputFile);
        BufferedReader reader = new BufferedReader(new FileReader(file));
        runBenchmarkWithZipfDistribution1(new NoopLock(), filename, threads, capacity, round, scanPercentage, scanLength, ReplacementAlgorithm.GClock, pageSize, reader);
        IOUtils.closeQuietly(reader);
    }
View Full Code Here

        System.gc();

        // LRU + spinlock
        String filename = FileUtils.basename(inputFile);
        BufferedReader reader = new BufferedReader(new FileReader(file));
        runBenchmarkWithZipfDistribution1(new AtomicBackoffLock(), filename, threads, capacity, round, scanPercentage, scanLength, ReplacementAlgorithm.LRU, pageSize, reader);
        IOUtils.closeQuietly(reader);

        System.gc();

        reader = new BufferedReader(new FileReader(file));
        runBenchmarkWithZipfDistribution2(new AtomicBackoffLock(), filename, threads, capacity, round, scanPercentage, scanLength, ReplacementAlgorithm.LRU, pageSize, reader);
        IOUtils.closeQuietly(reader);
    }
View Full Code Here

        System.gc();

        // LRU + sync
        String filename = FileUtils.basename(inputFile);
        BufferedReader reader = new BufferedReader(new FileReader(file));
        runBenchmarkWithZipfDistribution1(null, filename, threads, capacity, round, scanPercentage, scanLength, ReplacementAlgorithm.LRU, pageSize, reader);
        IOUtils.closeQuietly(reader);

        System.gc();

        reader = new BufferedReader(new FileReader(file));
        runBenchmarkWithZipfDistribution2(null, filename, threads, capacity, round, scanPercentage, scanLength, ReplacementAlgorithm.LRU, pageSize, reader);
        IOUtils.closeQuietly(reader);
    }
View Full Code Here

        System.gc();

        // 2Q + spinlock
        String filename = FileUtils.basename(inputFile);
        BufferedReader reader = new BufferedReader(new FileReader(file));
        runBenchmarkWithZipfDistribution2(new AtomicBackoffLock(), filename, threads, capacity, round, scanPercentage, scanLength, ReplacementAlgorithm.FullTwoQueue, pageSize, reader);
        IOUtils.closeQuietly(reader);
    }
View Full Code Here

        System.gc();

        // 2Q + sync
        String filename = FileUtils.basename(inputFile);
        BufferedReader reader = new BufferedReader(new FileReader(file));
        runBenchmarkWithZipfDistribution2(null, filename, threads, capacity, round, scanPercentage, scanLength, ReplacementAlgorithm.FullTwoQueue, pageSize, reader);
        IOUtils.closeQuietly(reader);
    }
View Full Code Here

   */
  public void setSource(InputStream in) throws IOException {
    m_File = (new File(System.getProperty("user.dir"))).getAbsolutePath();
    m_URL = "http://";

    m_sourceReader = new BufferedReader(new InputStreamReader(in));
  }
View Full Code Here

        //return new Object[][] { { "/tmp/zipfgen/1000k_zipf0.86_N50k.dat", 16, 16384, 62500, 20d, 100, 8 } };
        //return new Object[][] { { "/tmp/zipfgen/1000k_zipf0.86_N50k.dat", 8, 16384, 125000, 20d, 100, 8 } };
    }

    private static long[][] readDistribution(File file, int nthreads, int round) throws IOException {
        BufferedReader reader = new BufferedReader(new FileReader(file));
        long[][] dist = new long[nthreads][];
        for(int th = 0; th < nthreads; th++) {
            long[] curdist = new long[round];
            dist[th] = curdist;
            for(int i = 0; i < round; i++) {
                String line = reader.readLine();
                curdist[i] = Long.parseLong(line.trim());
            }
        }
        IOUtils.closeQuietly(reader);
        return dist;
View Full Code Here

TOP

Related Classes of java.io.BufferedReader

Copyright © 2015 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.