Package java.io

Examples of java.io.RandomAccessFile.readFully()


      }

      @Override
      public void readFully(byte[] b) throws IOException
      {
        f.readFully(b);
      }

      @Override
      public RandomAccessFile getUnderlyingFile()
      {
View Full Code Here


     */
    public static byte[] readFile(String fileName) throws IOException {
        RandomAccessFile file = new RandomAccessFile(fileName, "r");
        try {
            byte[] buff = new byte[(int) file.length()];
            file.readFully(buff);
            return buff;
        } finally {
            file.close();
        }
    }
View Full Code Here

    }

    private void checkJavadoc(File file) throws IOException {
        RandomAccessFile in = new RandomAccessFile(file, "r");
        byte[] data = new byte[(int) file.length()];
        in.readFully(data);
        in.close();
        String text = new String(data);
        int comment = text.indexOf("/**");
        if (comment < 0) {
            System.out.println("No Javadoc comment: " + file.getAbsolutePath());
View Full Code Here

     */
    public void checkOrFixFile(File file, boolean fix, boolean checkLicense) throws Exception {
        RandomAccessFile in = new RandomAccessFile(file, "r");
        byte[] data = new byte[(int) file.length()];
        ByteArrayOutputStream out = fix ? new ByteArrayOutputStream() : null;
        in.readFully(data);
        in.close();
        if (checkLicense) {
            if (data.length > COPYRIGHT.length() + LICENSE.length()) {
                // don't check tiny files
                String text = new String(data);
View Full Code Here

            long len = read.length();
            if (len >= Integer.MAX_VALUE) {
                throw new IOException("Files bigger than Integer.MAX_VALUE are not supported");
            }
            buffer = new byte[(int) len];
            read.readFully(buffer);
        } finally {
            read.close();
        }
        boolean found = false;
        // check for ## without creating a string
View Full Code Here

        value = dataFile.readUTF();
      } else {
        int n = dataFile.readInt();

        byte[] b = new byte[n];
        dataFile.readFully(b);

        value = b;
      }

      dataFile.close();
View Full Code Here

            Object key = OperationKey.newKey(dirName, name);

            Operation op = null;
            if (optype == Operation.SAVE) {
              byte buf[] = new byte[logFile.readInt()];
              logFile.readFully(buf);
              op = Operation.alloc(optype, dirName, name, buf);
              op = (Operation) templog.put(key, op);
            } else {
              op = Operation.alloc(optype, dirName, name);
              op = (Operation) templog.put(key, op);
View Full Code Here

        // Test for method void java.io.RandomAccessFile.readFully(byte [])
        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

        // int)
        byte[] buf = new byte[10];
        RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");
        raf.writeBytes("HelloWorld");
        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");
View Full Code Here

        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) {}
        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.