Package java.io

Examples of java.io.RandomAccessFile.readFully()


        raf.seek(0);
        raf.readFully(buf, 0, buf.length);
        assertEquals("Incorrect bytes read/written", "HelloWorld", new String(
                buf, 0, 10));
        try {
            raf.readFully(buf, 0, buf.length);
            fail("Reading past end of buffer did not throw EOFException");
        } catch (EOFException e) {}
    }

    /**
 
View Full Code Here


        byte[] buf = new byte[5];
        RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");
        raf.writeBytes("HelloWorld");
        raf.seek(0);
        raf.skipBytes(5);
        raf.readFully(buf);
        assertEquals("Failed to skip bytes", "World", new String(buf, 0, 5));
        raf.close();
    }

    /**
 
View Full Code Here

        // java.io.RandomAccessFile.writeBytes(java.lang.String)
        byte[] buf = new byte[10];
        RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");
        raf.writeBytes("HelloWorld");
        raf.seek(0);
        raf.readFully(buf);
        assertEquals("Incorrect bytes read/written", "HelloWorld", new String(
                buf, 0, 10));
        raf.close();

    }
View Full Code Here

            General.showDebug("New log size: " + newLogSize);
            try {
                RandomAccessFile raf = new RandomAccessFile(cingRunLogFile, "r");
                raf.seek(cingrunLogFileSizeLast);
                byte[] b = new byte[(int) newLogSize];
                raf.readFully(b);
                raf.close();
                lastLog = new String(b);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
                writeJsonError(response, result, "Failed to find cingRunLogFile: " + cingRunLogFile);
View Full Code Here

            // default platform encoding then we will need a new param that is
            // used here.
            scriptModified = scriptFile.lastModified();
            in = new RandomAccessFile(scriptFile, "r");
            byte[] bytes = new byte[(int) in.length()];
            in.readFully(bytes);
            cachedScript = new String(bytes);
            return cachedScript;
        }
        catch (Exception ex)
        {
View Full Code Here

                    // the end of the file and contains the magic
                    // value 0xFFFF as "number of entries".
                    a.seek(end
                           - 22 /* length of EOCD without file comment */);
                    byte[] eocd = new byte[12];
                    a.readFully(eocd);
                    assertArrayEquals(new byte[] {
                            // sig
                            (byte) 0x50, (byte) 0x4b, 5, 6,
                            // disk numbers
                            0, 0, 0, 0,
View Full Code Here

                        - 56 /* z64 eocd without extensible data sector */;
                    byte[] loc =
                        ZipEightByteInteger.getBytes(expectedZ64EocdOffset);
                    a.seek(end - 22 - 20);
                    byte[] z64EocdLoc = new byte[20];
                    a.readFully(z64EocdLoc);
                    assertArrayEquals(new byte[] {
                            // sig
                            (byte) 0x50, (byte) 0x4b, 6, 7,
                            // disk numbers
                            0, 0, 0, 0,
View Full Code Here

                    // record" is where it is supposed to be, the
                    // known values are fine and read the location
                    // of the central directory from it
                    a.seek(expectedZ64EocdOffset);
                    byte[] z64EocdStart = new byte[40];
                    a.readFully(z64EocdStart);
                    assertArrayEquals(new byte[] {
                            // sig
                            (byte) 0x50, (byte) 0x4b, 6, 6,
                            // size of z64 EOCD
                            44, 0, 0, 0,
View Full Code Here

                            (byte) 0xA0, (byte) 0x86, 1, 0,
                            0, 0, 0, 0,
                        }, z64EocdStart);
                    a.seek(expectedZ64EocdOffset + 48 /* skip size */);
                    byte[] cdOffset = new byte[8];
                    a.readFully(cdOffset);
                    long cdLoc = ZipEightByteInteger.getLongValue(cdOffset);

                    // finally verify there really is a central
                    // directory entry where the Zip64 EOCD claims
                    a.seek(cdLoc);
View Full Code Here

                    // finally verify there really is a central
                    // directory entry where the Zip64 EOCD claims
                    a.seek(cdLoc);
                    byte[] sig = new byte[4];
                    a.readFully(sig);
                    assertArrayEquals(new byte[] {
                            (byte) 0x50, (byte) 0x4b, 1, 2,
                        }, sig);
                } finally {
                    a.close();
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.