Package java.io

Examples of java.io.RandomAccessFile.readLine()


    List<Integer> l = new ArrayList<Integer>();
    RandomAccessFile raf = new RandomAccessFile(f, "r");
    String line = null;
    int pos = 0;
    do {
      line = raf.readLine();
      if(line != null) l.add(pos);
      pos = (int)(raf.getFilePointer());
      //while(line != null && line.length() == 0) line = raf.readLine();
    } while(line != null);
    daos.writeInt(l.size());
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
        {
View Full Code Here

        tail.append("\n-------------------- "+tag+"---------------------\n");
        String[] lines = null;
        if (num >0) {
          lines = new String[num];
        }
        while ((line = rafile.readLine()) != null) {
          no_lines++;
          if (num >0) {
            if (no_lines <= num) {
              lines[no_lines-1] = line;
            }
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

    private static void putDtdReference(String dtdFileName, String outputXmlFileName) throws IOException {
        RandomAccessFile xml = new RandomAccessFile(outputXmlFileName, "rw");
        int beginIndex = Math.max(dtdFileName.lastIndexOf("/"), dtdFileName.lastIndexOf(File.separator));
        String rootElementName = dtdFileName.substring(beginIndex+1, dtdFileName.lastIndexOf(".dtd"));
        String dtdReference = "<!DOCTYPE "+rootElementName+" SYSTEM \'"+dtdFileName+"\'>"+'\n';
        xml.readLine();
        long posicao = xml.getFilePointer();
        String aux1 = xml.readLine();
        xml.seek(posicao);
        xml.writeBytes(dtdReference);
        do {
View Full Code Here

        int beginIndex = Math.max(dtdFileName.lastIndexOf("/"), dtdFileName.lastIndexOf(File.separator));
        String rootElementName = dtdFileName.substring(beginIndex+1, dtdFileName.lastIndexOf(".dtd"));
        String dtdReference = "<!DOCTYPE "+rootElementName+" SYSTEM \'"+dtdFileName+"\'>"+'\n';
        xml.readLine();
        long posicao = xml.getFilePointer();
        String aux1 = xml.readLine();
        xml.seek(posicao);
        xml.writeBytes(dtdReference);
        do {
            posicao = xml.getFilePointer();
            String aux2 = xml.readLine();
View Full Code Here

        String aux1 = xml.readLine();
        xml.seek(posicao);
        xml.writeBytes(dtdReference);
        do {
            posicao = xml.getFilePointer();
            String aux2 = xml.readLine();
            xml.seek(posicao);
            xml.writeBytes(aux1);
            aux2 = xml.readLine();
        } while(!"".equals(aux1));
        xml.close();
View Full Code Here

        do {
            posicao = xml.getFilePointer();
            String aux2 = xml.readLine();
            xml.seek(posicao);
            xml.writeBytes(aux1);
            aux2 = xml.readLine();
        } while(!"".equals(aux1));
        xml.close();
    }
}
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

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.