Package java.io

Examples of java.io.RandomAccessFile.readLine()


        randomAccessFile.seek(offset);
        //log.debug("SKIP IS ::" + offset);

        String line = null;
        String lineUTF8 = null;
        while ((line = randomAccessFile.readLine()) != null) {
            lineUTF8 = new String(line.getBytes("ISO8859_1"), "UTF-8");
            lineTotal++;
            buffer.append(lineUTF8).append("\n");
        }
    } finally {
View Full Code Here


        RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");
        String s = "Goodbye\nCruel\nWorld\n";
        raf.write(s.getBytes("UTF-8"), 0, s.length());
        raf.seek(0);

        assertEquals("Goodbye", raf.readLine());
        assertEquals("Cruel", raf.readLine());
        assertEquals("World", raf.readLine());
       
        raf.close();
    }
View Full Code Here

        String s = "Goodbye\nCruel\nWorld\n";
        raf.write(s.getBytes("UTF-8"), 0, s.length());
        raf.seek(0);

        assertEquals("Goodbye", raf.readLine());
        assertEquals("Cruel", raf.readLine());
        assertEquals("World", raf.readLine());
       
        raf.close();
    }
View Full Code Here

        raf.write(s.getBytes("UTF-8"), 0, s.length());
        raf.seek(0);

        assertEquals("Goodbye", raf.readLine());
        assertEquals("Cruel", raf.readLine());
        assertEquals("World", raf.readLine());
       
        raf.close();
    }

    /**
 
View Full Code Here

          }
          raf.seek(len-TESTRESULTS_END.length()-10);//TODO: may not work on all OSes?
          String line;
          long pos = raf.getFilePointer();
          int end=0;
          while((line = raf.readLine()) != null)// reads to end of line OR file
          {
              end = line.indexOf(TESTRESULTS_END);
              if (end >= 0) // found the string
              {
                break;
View Full Code Here

      try {
        res = file.getChannel().tryLock();
        file.write(jvmName.getBytes());
        LOG.info("Lock on " + lockF + " acquired by nodename " + jvmName);
      } catch(OverlappingFileLockException oe) {
        LOG.error("It appears that another namenode " + file.readLine()
            + " has already locked the storage directory");
        file.close();
        return null;
      } catch(IOException e) {
        LOG.error("Failed to acquire lock on " + lockF + ". If this storage directory is mounted via NFS, "
View Full Code Here

        RandomAccessFile raf = new java.io.RandomAccessFile(fileName, "rw");
        String s = "Goodbye\nCruel\nWorld\n";
        raf.write(s.getBytes(), 0, s.length());
        raf.seek(0);

        assertEquals("Goodbye", raf.readLine());
        assertEquals("Cruel", raf.readLine());
        assertEquals("World", raf.readLine());
    }

    /**
 
View Full Code Here

        String s = "Goodbye\nCruel\nWorld\n";
        raf.write(s.getBytes(), 0, s.length());
        raf.seek(0);

        assertEquals("Goodbye", raf.readLine());
        assertEquals("Cruel", raf.readLine());
        assertEquals("World", raf.readLine());
    }

    /**
     * @tests java.io.RandomAccessFile#readLong()
View Full Code Here

        raf.write(s.getBytes(), 0, s.length());
        raf.seek(0);

        assertEquals("Goodbye", raf.readLine());
        assertEquals("Cruel", raf.readLine());
        assertEquals("World", raf.readLine());
    }

    /**
     * @tests java.io.RandomAccessFile#readLong()
     */
 
View Full Code Here

        res = file.getChannel().tryLock();
        file.write(jvmName.getBytes(Charsets.UTF_8));
        LOG.info("Lock on " + lockF + " acquired by nodename " + jvmName);
      } catch(OverlappingFileLockException oe) {
        // Cannot read from the locked file on Windows.
        String lockingJvmName = Path.WINDOWS ? "" : (" " + file.readLine());
        LOG.error("It appears that another namenode" + lockingJvmName
            + " has already locked the storage directory");
        file.close();
        return null;
      } catch(IOException e) {
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.