Package java.io

Examples of java.io.RandomAccessFile.writeByte()


     * @tests java.io.RandomAccessFile#writeByte(int)
     */
    public void test_writeByteI() throws IOException {
        // Test for method void java.io.RandomAccessFile.writeByte(int)
        RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");
        raf.writeByte(127);
        raf.seek(0);
        assertEquals("Incorrect byte read/written", 127, raf.readByte());
        raf.close();
    }

View Full Code Here


     * @tests java.io.RandomAccessFile#writeByte(int)
     */
    public void test_writeByteI() throws IOException {
        // Test for method void java.io.RandomAccessFile.writeByte(int)
        RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");
        raf.writeByte(127);
        raf.seek(0);
        assertEquals("Incorrect byte read/written", 127, raf.readByte());
        raf.close();
    }

View Full Code Here

     * @tests java.io.RandomAccessFile#readByte()
     */
    public void test_readByte() throws IOException {
        // Test for method byte java.io.RandomAccessFile.readByte()
        RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");
        raf.writeByte(127);
        raf.seek(0);
        assertEquals("Incorrect bytes read/written", 127, raf.readByte());
        raf.close();
    }

View Full Code Here

     * @tests java.io.RandomAccessFile#readUnsignedByte()
     */
    public void test_readUnsignedByte() throws IOException {
        // Test for method int java.io.RandomAccessFile.readUnsignedByte()
        RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");
        raf.writeByte(-1);
        raf.seek(0);
        assertEquals("Incorrect byte read/written", 255, raf.readUnsignedByte());
        raf.close();
    }

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

                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

    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

                // is it just 1 big write?
                if (wb.size == write.location.getSize()) {

                    // 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

                raf = getDescriptor();
                if (this.offset >= raf.length()) {
                    // Grow the file
                    long o = (fileHeader.headerSize + ((fileHeader.totalCount * 3) / 2) * fileHeader.pageSize) + (fileHeader.pageSize - 1);
                    raf.seek(o);
                    raf.writeByte(0);
                }
                raf.seek(this.offset);
                raf.write(this.data);
            } finally {
                putDescriptor(raf);
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

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.