Examples of FileChannel


Examples of java.nio.channels.FileChannel

      }
    }
  }
 
  public static void copyFile(File in, File outDir) throws IOException {
       FileChannel sourceChannel = null;
       FileChannel destinationChannel=null;
       try{
         sourceChannel= new
              FileInputStream(in).getChannel();
        
         File out=new File(outDir,in.getName());
         destinationChannel = new
              FileOutputStream(out).getChannel();
         sourceChannel.transferTo(0, sourceChannel.size(), destinationChannel);
       }
       finally{
         try{
           if (sourceChannel!=null){
             sourceChannel.close();
           }
         }
         finally{
           if (destinationChannel!=null){
             destinationChannel.close();
           }
         }
       }
  }
View Full Code Here

Examples of org.apache.flume.channel.file.FileChannel

      reader.close();

    }
    FileChannelIntegrityTool tool = new FileChannelIntegrityTool();
    tool.run(new String[] {"-l", dataDir.toString()});
    FileChannel channel = new FileChannel();
    channel.setName("channel");
    String cp;
    if(withCheckpoint) {
      cp = origCheckpointDir.toString();
    } else {
      FileUtils.deleteDirectory(checkpointDir);
      Assert.assertTrue(checkpointDir.mkdirs());
      cp = checkpointDir.toString();
    }
    ctx.put(FileChannelConfiguration.CHECKPOINT_DIR,cp);
    ctx.put(FileChannelConfiguration.DATA_DIRS, dataDir.toString());
    channel.configure(ctx);
    channel.start();
    Transaction tx = channel.getTransaction();
    tx.begin();
    int i = 0;
    while(channel.take() != null) {
      i++;
    }
    tx.commit();
    tx.close();
    channel.stop();
    Assert.assertEquals(25 - corrupted, i);
    files = dataDir.listFiles(new FilenameFilter() {
      @Override
      public boolean accept(File dir, String name) {
        if(name.contains(".bak")) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.