Package java.io

Examples of java.io.RandomAccessFile.readFully()


      //truncate blockFile
      blockRAF.setLength(newlen);
      //read last chunk
      blockRAF.seek(lastchunkoffset);
      blockRAF.readFully(b, 0, lastchunksize);
    } finally {
      blockRAF.close();
    }

    //compute checksum
View Full Code Here


      raf = new RandomAccessFile(bootIDFile, "rw");
      if(raf.length() < BOOT_FILE_LENGTH) {
        oldBootID = -1;
      } else {
        byte[] buf = new byte[BOOT_FILE_LENGTH];
        raf.readFully(buf);
        String s = new String(buf, "ISO-8859-1");
        try {
          oldBootID = Fields.bytesToLong(HexUtil.hexToBytes(s));
        } catch (NumberFormatException e) {
          oldBootID = -1;
View Full Code Here

      try {
        // try to load
        RandomAccessFile raf = new RandomAccessFile(configFile, "r");
        try {
          byte[] salt = new byte[0x10];
          raf.readFully(salt);

          byte[] diskSalt = salt;
          if(masterKey != null) {
            BlockCipher cipher;
            try {
View Full Code Here

    @BeforeClass
    public static void before() throws Exception {
        RandomAccessFile f = new RandomAccessFile(new File(MockTest.class.getResource("/org/jooq/test/data/db.txt").toURI()), "r");
        byte[] b = new byte[(int) f.length()];
        f.readFully(b);
        String s = new String(b);
        s = s.replace("{version}", Constants.FULL_VERSION);

        MOCK = DSL.using(new MockConnection(new MockFileDatabase(s)), SQLDialect.POSTGRES);
    }
View Full Code Here

        buf.flush();

        file.seek(0);
        byte[] expect = "Hello, world!".getBytes(Charset.forName("ascii"));
        byte[] b = new byte[expect.length];
        file.readFully(b);
        assertThat(b, is(expect));

        eof(file);
    }
View Full Code Here

        buf.flush();
        assertThat(buf.getPosition(), is(256L));

        file.seek(0);
        byte[] b = new byte[256];
        file.readFully(b);
        assertThat(b, is(range(0, 255)));

        eof(file);
    }
View Full Code Here

        buf.flush();
        assertThat(buf.getPosition(), is(200L));

        file.seek(0);
        byte[] b = new byte[200];
        file.readFully(b);
        assertThat(b, is(range(1, 200)));

        eof(file);
    }
View Full Code Here

        try {
            RandomAccessFile f = new RandomAccessFile(file, "r");

            try {
                byte[] bytes = new byte[(int) f.length()];
                f.readFully(bytes);
                String string = new String(bytes);

                Matcher matcher = Pattern.compile("@javax.annotation.Generated\\(value\\s+= \\{.*?\"schema version:(.*?)\" \\},").matcher(string);
                if (matcher.find()) {
                    result = matcher.group(1);
View Full Code Here

                RandomAccessFile old = null;

                try {
                    old = new RandomAccessFile(file, "r");
                    byte[] oldBytes = new byte[(int) old.length()];
                    old.readFully(oldBytes);
                    oldContent = new String(oldBytes, "UTF-8");
                }
                finally {
                    if (old != null)
                        old.close();
View Full Code Here

                try
                {
                    byte[] data = new byte[(int)(fileLength - readFrom)];
                   
                    randomAccessFile.seek(readFrom);
                    randomAccessFile.readFully(data);
                   
                    return data;
                }
                catch (IOException ioe)
                {
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.