Package java.io

Examples of java.io.RandomAccessFile.seek()


    @Override
    void markCheckpoint(long currentPosition, long logWriteOrderID)
        throws IOException {
      RandomAccessFile writeFileHandle = getFileHandle();
      writeFileHandle.seek(OFFSET_CHECKPOINT);
      writeFileHandle.writeLong(currentPosition);
      writeFileHandle.writeLong(logWriteOrderID);
      writeFileHandle.getChannel().force(true);
      LOGGER.info("Noted checkpoint for file: " + getFile() + ", id: "
          + getLogFileID() + ", checkpoint position: " + currentPosition
View Full Code Here


    PCFBMode pcfb = PCFBMode.create(cipher, iv);
    pcfb.blockEncipher(data, hashedStart, data.length - hashedStart);

    RandomAccessFile raf = new RandomAccessFile(masterKeysFile, "rw");

    raf.seek(0);
    raf.write(data);
    long len = raf.length();
    if(len > data.length) {
      byte[] diff = new byte[(int)(len - data.length)];
      raf.write(diff);
View Full Code Here

            if (length > (file.length() - offset)) {
                return null;
            }

            byte[] buf = new byte[length];
            file.seek(offset);

            int bytesRead = 0;
            int size = 0;
            boolean gotAllBytes = false;
            boolean done = false;
View Full Code Here

            long fptr = Math.max(file.length() - bufferSize, 0);
            long fptrEof = 0;

            while (fptr > 0) {
                byte [] buffer = new byte[bufferSize];
                raf.seek(fptr);
                raf.read(buffer, 0, bufferSize);
                int eventStart = getEventStart(buffer, format);
                if (eventStart != -1) {
                    fptrEof = nextEventOffset + fptr;
                    break;
View Full Code Here

            try {
                while(true) {
                    index.readFully(keyMd5);
                    position = index.readInt();

                    data.seek(position);
                    int size = data.readInt();
                    byte[] value = new byte[size];
                    data.readFully(value);
                    System.out.println(ByteUtils.toHexString(keyMd5) + "\t=>\t"
                                       + serializer.toObject(value).toString());
View Full Code Here

      }

      // Open file and seek to the end of it.
      file = new RandomAccessFile(this.path + this.getFileName(this.url),
          "rw");
      file.seek(this.downloaded);

      stream = connection.getInputStream();
      while (this.status == DOWNLOADING) {
        /*
         * Size buffer according to how much of the file is left to
View Full Code Here

                    Thread.sleep(delayMillis);
                } else {
                    // The current position in the file
                    position = end ? file.length() : 0;
                    last = file.lastModified();
                    reader.seek(position);
                }
            }
            while (getRun()) {
                final boolean newer = FileUtils.isFileNewer(file, last); // IO-279, must be done first
                // Check the file length to see if it was rotated
View Full Code Here

  public synchronized InputStream getBlockInputStream(Block b, long seekOffset) throws IOException {

    File blockFile = getBlockFile(b);
    RandomAccessFile blockInFile = new RandomAccessFile(blockFile, "r");
    if (seekOffset > 0) {
      blockInFile.seek(seekOffset);
    }
    return new FileInputStream(blockInFile.getFD());
  }

  /**
 
View Full Code Here

    if (blockFile == null) {
      blockFile = v.getTmpFile(b);
    }
    RandomAccessFile blockInFile = new RandomAccessFile(blockFile, "r");
    if (blkOffset > 0) {
      blockInFile.seek(blkOffset);
    }
    File metaFile = getMetaFile(blockFile, b);
    RandomAccessFile metaInFile = new RandomAccessFile(metaFile, "r");
    if (ckoff > 0) {
      metaInFile.seek(ckoff);
View Full Code Here

    public void read(File from) throws IOException {
      RandomAccessFile file = new RandomAccessFile(from, "rws");
      FileInputStream in = null;
      try {
        in = new FileInputStream(file.getFD());
        file.seek(0);
        Properties props = new Properties();
        props.load(in);
        getFields(props, this);
      } finally {
        if (in != null) {
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.