Package java.io

Examples of java.io.RandomAccessFile.writeByte()


     * @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


     * @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

                {
                    String sLine = getItem(i);
                    if (sLine.startsWith("["))
                    {
                        // write an extra empty line before next section.
                        aWriter.writeByte((int) '\n');
                    }
                    aWriter.writeBytes(sLine);
                    aWriter.writeByte((int) '\n');
                }
                aWriter.close();
View Full Code Here

                    {
                        // write an extra empty line before next section.
                        aWriter.writeByte((int) '\n');
                    }
                    aWriter.writeBytes(sLine);
                    aWriter.writeByte((int) '\n');
                }
                aWriter.close();
            }
            catch (java.io.FileNotFoundException fne)
            {
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

     * @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

                raf = getDescriptor();
                if (this.offset >= raf.length()) {
                    // Grow the file
                    long o = fileHeader.headerSize + (fileHeader.totalCount * 3 / 2 + 1) * fileHeader.pageSize - 1;
                    raf.seek(o);
                    raf.writeByte(0);
                }
                raf.seek(this.offset);
                raf.write(this.data);
            } finally {
                putDescriptor(raf);
View Full Code Here

        ObjectVersion previousVersion = (ObjectVersion) previous.getVersion();
        if (previousVersion.isCurrent) {
          previousVersion.isCurrent = false;
          RandomAccessFile transactionsFile = getTransactionsReadFile();
          transactionsFile.seek(previousVersionReference + 1);
          transactionsFile.writeByte(0); // set it to be a non-current version
        }
        return previous;
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
View Full Code Here

    Files.copy(i18nFile, temp);
    assertTrue(Files.equal(i18nFile, temp));

    Files.copy(asciiFile, temp);
    RandomAccessFile rf = new RandomAccessFile(temp, "rw");
    rf.writeByte(0);
    rf.close();
    assertEquals(asciiFile.length(), temp.length());
    assertFalse(Files.equal(asciiFile, temp));

    assertTrue(Files.asByteSource(asciiFile)
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.