Package java.io

Examples of java.io.RandomAccessFile


                    Debug.output("DTEDAdmin copying " + file.getAbsolutePath()
                            + " to " + outputFile.getAbsolutePath());
                }

                BinaryBufferedFile input = new BinaryBufferedFile(file);
                RandomAccessFile output = new RandomAccessFile(outputFile, "rw");
                byte[] bytes = new byte[4096];
                int numBytes = input.read(bytes);
                while (numBytes > 0) {
                    output.write(bytes, 0, numBytes);
                    numBytes = input.read(bytes);
                }

                input.close();
                output.close();

            } catch (FormatException fe) {
                continue;
            } catch (IOException ioe) {
                continue;
View Full Code Here


  }
 
  public MetFile(File file) {
    try {
      this.file = file;
      fileChannel = new RandomAccessFile(file,"rws").getChannel();
    }catch(Throwable t) {
      fileChannel = null;
    }
  }
View Full Code Here

  public FileChunk getData(FileChunkRequest chunkData) throws SharedFileException{
    if (readChannel == null) {
      synchronized(FileChannel.class) {
        try {
          readChannel = new RandomAccessFile(file,"rws").getChannel();
        } catch (FileNotFoundException e) {
          e.printStackTrace();
          throw new SharedFileException("Failed to open file : " + file.getName());
        }
      }
View Full Code Here

  }
 
  public void updateHashes() throws SharedFileException {
    if (readChannel == null)
      try {
        readChannel = new RandomAccessFile(file,"rws").getChannel();
      } catch (FileNotFoundException e) {
        throw new SharedFileException("Shared file not found");
      }
    PartHashSet newSets = MD4FileHasher.calcHashSets(readChannel);
    hashSet = newSets;
View Full Code Here

    try
    {
      // Get a file channel for the SourceFile
      File lockSourceFile = new File(sourceFile);
      srcChannel = new RandomAccessFile(lockSourceFile, "r")
          .getChannel();

      // Create channel on the destination
      fos = new FileOutputStream(targetFile);
      dstChannel = fos.getChannel();
View Full Code Here

       
        FutureResponseHandler respHdl = new FutureResponseHandler();
        BodyDataSink dataSink = con.send(new HttpRequestHeader("POST", "http://localhost:" + server.getLocalPort() + "/"), respHdl);
       
       
        RandomAccessFile raf = new RandomAccessFile(file, "r");
        FileChannel fc = raf.getChannel();
        dataSink.transferFrom(fc);
        fc.close();
        raf.close();
        dataSink.close();
       
        IHttpResponse response = respHdl.getResponse();
       
        Assert.assertEquals(200, response.getStatus());
View Full Code Here

       
        FutureResponseHandler respHdl = new FutureResponseHandler();
        BodyDataSink dataSink = con.send(new HttpRequestHeader("POST", "http://localhost:" + server.getLocalPort() + "/"), respHdl);
       
       
        RandomAccessFile raf = new RandomAccessFile(file, "r");
        FileChannel fc = raf.getChannel();
        dataSink.transferFrom(fc);
        fc.close();
        raf.close();
        dataSink.close();
       
        IHttpResponse response = respHdl.getResponse();
       
        Assert.assertEquals(200, response.getStatus());
View Full Code Here

   */
  public static List<KadContact> loadFile(String fileName) {
    List<KadContact> result = new LinkedList<KadContact>();
   
    try {
      FileChannel channel = new RandomAccessFile(fileName,"rw").getChannel();
     
      ByteBuffer data = getByteBuffer(4);
      channel.position(4); // skip 'old' contacts count field
     
      channel.read(data); // nodes.dat version
View Full Code Here

    String tempDir = ConfigurationManager.TEMP_DIR;
   
    file = new File(tempDir+File.separator+partFile.getTempFileName());
   
    try {
      readChannel = new RandomAccessFile(file,"rws").getChannel();
      readChannel.position(0);
    } catch (Throwable e) {
      throw new SharedFileException("Failed to open "+file+"\n"+Misc.getStackTrace(e));
    }
   
    try {
      writeChannel = new RandomAccessFile(file,"rws").getChannel();
      writeChannel.position(0);
    } catch (Throwable e) {
      throw new SharedFileException("Failed to open "+file+"\n"+Misc.getStackTrace(e));
    }
   
View Full Code Here

    metFileName = tempDir + File.separator+fileName +  PartMet.PART_MET_FILE_EXTENTSION;
   
    file = new File(tempFileName);
   
    try {
      readChannel = new RandomAccessFile(file,"rws").getChannel();
      readChannel.position(0);
    } catch (Throwable e) {
      throw new SharedFileException("Failed to open "+file+"\n"+Misc.getStackTrace(e));
    }
   
    try {
      writeChannel = new RandomAccessFile(file,"rws").getChannel();
      writeChannel.position(0);
    } catch (Throwable e) {
      throw new SharedFileException("Failed to open "+file+"\n"+Misc.getStackTrace(e));
    }
   
View Full Code Here

TOP

Related Classes of java.io.RandomAccessFile

Copyright © 2018 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.