Package java.io

Examples of java.io.RandomAccessFile.writeShort()


            /* Output ID list. */
            raf.writeByte(ZoneInfoFile.TAG_ZoneAliases);
            index += 3 + block_size;
            block_size = 2;
            raf.writeShort(block_size & 0xFFFF);
            raf.writeShort(a.size() & 0xFFFF);
            for (String key : a.keySet()) {
                String alias = a.get(key);
                byte key_size = (byte)key.length();
                byte alias_size = (byte)alias.length();
View Full Code Here


            /* Output ID list. */
            raf.writeByte(ZoneInfoFile.TAG_ZoneAliases);
            index += 3 + block_size;
            block_size = 2;
            raf.writeShort(block_size & 0xFFFF);
            raf.writeShort(a.size() & 0xFFFF);
            for (String key : a.keySet()) {
                String alias = a.get(key);
                byte key_size = (byte)key.length();
                byte alias_size = (byte)alias.length();
                raf.writeByte(key_size & 0xFF);
View Full Code Here

                raf.write(alias.getBytes("UTF-8"), 0, alias_size);
                block_size += 2 + key_size + alias_size;
            }
            fp = raf.getFilePointer();
            raf.seek(index);
            raf.writeShort((block_size) & 0xFFFF);
            raf.seek(fp);

            /* Output the exclude list if it exists. */
            List<String> excludedZones = map.getExcludeList();
            if (excludedZones != null) {
View Full Code Here

            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) {
                    byte size = (byte) name.length();
                    raf.writeByte(size);                 // byte length
                    raf.write(name.getBytes("UTF-8"), 0, size); // zone name
View Full Code Here

            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) {
                    byte size = (byte) name.length();
                    raf.writeByte(size);                 // byte length
                    raf.write(name.getBytes("UTF-8"), 0, size); // zone name
                    block_size += 1 + size;
View Full Code Here

                    raf.write(name.getBytes("UTF-8"), 0, size); // zone name
                    block_size += 1 + size;
                }
                fp = raf.getFilePointer();
                raf.seek(index);
                raf.writeShort(block_size & 0xFFFF);
                raf.seek(fp);
            }

            /* Close ZoneInfoMapping file. */
            raf.close();
View Full Code Here

     * @tests java.io.RandomAccessFile#readShort()
     */
    public void test_readShort() throws IOException {
        // Test for method short java.io.RandomAccessFile.readShort()
        RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");
        raf.writeShort(Short.MIN_VALUE);
        raf.seek(0);
        assertEquals("Incorrect long read/written", Short.MIN_VALUE, raf
                .readShort());
        raf.close();
    }
View Full Code Here

     * @tests java.io.RandomAccessFile#readUnsignedShort()
     */
    public void test_readUnsignedShort() throws IOException {
        // Test for method int java.io.RandomAccessFile.readUnsignedShort()
        RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");
        raf.writeShort(-1);
        raf.seek(0);
        assertEquals("Incorrect byte read/written", 65535, raf
                .readUnsignedShort());
        raf.close();
    }
View Full Code Here

     * @tests java.io.RandomAccessFile#writeShort(int)
     */
    public void test_writeShortI() throws IOException {
        // Test for method void java.io.RandomAccessFile.writeShort(int)
        RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");
        raf.writeShort(Short.MIN_VALUE);
        raf.seek(0);
        assertEquals("Incorrect long read/written", Short.MIN_VALUE, raf
                .readShort());
        raf.close();
    }
View Full Code Here

     * @tests java.io.RandomAccessFile#readShort()
     */
    public void test_readShort() throws IOException {
        // Test for method short java.io.RandomAccessFile.readShort()
        RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");
        raf.writeShort(Short.MIN_VALUE);
        raf.seek(0);
        assertEquals("Incorrect long read/written", Short.MIN_VALUE, raf
                .readShort());
        raf.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.