Package java.io

Examples of java.io.RandomAccessFile.readLine()


        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.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 end of file
            {
                end = line.indexOf(TESTRESULTS_END);
                if (end >= 0) // found the string
                {
                    break;
View Full Code Here

      int lines  = 0;
      try {
        rf = new RandomAccessFile(file, RMODE);
        ln = rf.length();
        rf.seek(seekPos);
        String tmp = rf.readLine();
        while (tmp != null) {
          lines++;
          sb.append(tmp);
          //sb.append(Character.LINE_SEPARATOR);
          sb.append('\n'); // adding a newline character is going to add one extra byte
View Full Code Here

        while (tmp != null) {
          lines++;
          sb.append(tmp);
          //sb.append(Character.LINE_SEPARATOR);
          sb.append('\n'); // adding a newline character is going to add one extra byte
          tmp = rf.readLine();
        }
      }
      catch (Exception e) {
        //e.printStackTrace(); //ignore
      }
View Full Code Here

      int lines  = 0;
      try {
        rf = new RandomAccessFile(file, RMODE);
        ln = rf.length();
        rf.seek(seekPos);
        String tmp = rf.readLine();
        while (tmp != null) {
          lines++;
          sb.append(tmp);
          //sb.append(Character.LINE_SEPARATOR);
          sb.append('\n'); // adding a newline character is going to add one extra byte
View Full Code Here

        while (tmp != null) {
          lines++;
          sb.append(tmp);
          //sb.append(Character.LINE_SEPARATOR);
          sb.append('\n'); // adding a newline character is going to add one extra byte
          tmp = rf.readLine();
        }
      }
      catch (Exception e) {
        //e.printStackTrace(); //ignore
      }
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 end of file
            {
                end = line.indexOf(TESTRESULTS_END);
                if (end >= 0) // found the string
                {
                    break;
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

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.