Package java.io

Examples of java.io.RandomAccessFile.writeByte()


                String alias = a.get(key);
                byte key_size = (byte)key.length();
                byte alias_size = (byte)alias.length();
                raf.writeByte(key_size & 0xFF);
                raf.write(key.getBytes("UTF-8"), 0, key_size);
                raf.writeByte(alias_size & 0xFF);
                raf.write(alias.getBytes("UTF-8"), 0, alias_size);
                block_size += 2 + key_size + alias_size;
            }
            fp = raf.getFilePointer();
            raf.seek(index);
View Full Code Here


            raf.seek(fp);

            /* Output the exclude list if it exists. */
            List<String> excludedZones = map.getExcludeList();
            if (excludedZones != null) {
                raf.writeByte(ZoneInfoFile.TAG_ExcludedZones);
                index += 3 + block_size;
                block_size = 2;
                raf.writeShort(block_size & 0xFFFF)// place holder
                raf.writeShort(excludedZones.size()); // the number of excluded zones
                for (String name : excludedZones) {
View Full Code Here

                block_size = 2;
                raf.writeShort(block_size & 0xFFFF)// place holder
                raf.writeShort(excludedZones.size()); // the number of excluded zones
                for (String name : excludedZones) {
                    byte size = (byte) name.length();
                    raf.writeByte(size);                 // byte length
                    raf.write(name.getBytes("UTF-8"), 0, size); // zone name
                    block_size += 1 + size;
                }
                fp = raf.getFilePointer();
                raf.seek(index);
View Full Code Here

                if (wb.size == write.location.getSize()) {
                    forceToDisk = write.sync | write.onComplete!=null;
                   
                    // Just write it directly..
                    file.writeInt(write.location.getSize());
                    file.writeByte(write.location.getType());
                    file.write(RESERVED_SPACE);
                    file.write(AsyncDataManager.ITEM_HEAD_SOR);
                    file.write(write.data.getData(), write.data.getOffset(), write.data.getLength());
                    file.write(AsyncDataManager.ITEM_HEAD_EOR);
View Full Code Here

    RandomAccessFile raf = new RandomAccessFile(file,"rws");
    Random random = new Random();
    for (long i = 0; i < raf.length(); i++) {
      raf.seek(i);
      if (random.nextBoolean()) {
        raf.writeByte(random.nextInt());
      }
    }
    raf.close();
  }
 
View Full Code Here

    RandomAccessFile raf = new RandomAccessFile(file, "rw");
    try {
      raf.seek(offset);
      int origByte = raf.read();
      raf.seek(offset);
      raf.writeByte(origByte - 1);
    } finally {
      IOUtils.closeStream(raf);
    }
  }
View Full Code Here

                RandomAccessFile aWriter = new RandomAccessFile(aFile, "rw");
                for (int i=0; i<m_aList.size();i++)
                {
                    String sLine = getItem(i);
                    aWriter.writeBytes(sLine);
                    aWriter.writeByte((int)'\n');
                }
                aWriter.close();
            }
           
            catch (java.io.FileNotFoundException fne)
View Full Code Here

                                              LogEntryHeader.FLAGS_OFFSET);
                file.seek(entryFlagsOffset);
                byte flags = file.readByte();
                byte newFlags = LogEntryHeader.makeInvisible(flags);
                file.seek(entryFlagsOffset);
                file.writeByte(newFlags);
            }
        } catch (IOException e) {
            throw new EnvironmentFailureException
                (envImpl,
                 EnvironmentFailureReason.LOG_WRITE,
View Full Code Here

    RandomAccessFile raf = new RandomAccessFile(file, "rw");
    try {
      raf.seek(offset);
      int origByte = raf.read();
      raf.seek(offset);
      raf.writeByte(origByte - 1);
    } finally {
      IOUtils.closeStream(raf);
    }
  }
View Full Code Here

           
            // block resource by ourself
            try
            {
                RandomAccessFile aWriter = new RandomAccessFile(_aSemaphore, "rw");
                aWriter.writeByte((int)1);
                aWriter.close();
            }
           
            catch (java.io.FileNotFoundException fne)
            {
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.