Java 类java.io.LineNumberReader 实例源码

项目:AndroidSerialPort    文件:SerialPortFinder.java   
Vector<Driver> getDrivers() throws IOException {
    if (mDrivers == null) {
        mDrivers = new Vector<Driver>();
        LineNumberReader r = new LineNumberReader(new FileReader("/proc/tty/drivers"));
        String l;
        while((l = r.readLine()) != null) {
            // Issue 3:
            // Since driver name may contain spaces, we do not extract driver name with split()
            String drivername = l.substring(0, 0x15).trim();
            String[] w = l.split(" +");
            if ((w.length >= 5) && (w[w.length-1].equals("serial"))) {
                Log.d(TAG, "Found new driver " + drivername + " on " + w[w.length-4]);
                mDrivers.add(new Driver(drivername, w[w.length-4]));
            }
        }
        r.close();
    }
    return mDrivers;
}
项目:publicProject    文件:GlobalVariable.java   
/**
 * 获取Mac
 */
private String getMac() {
    String macSerial = null;
    String str = null;
    try {
        Process pp = Runtime.getRuntime().exec("cat /sys/class/net/wlan0/address ");
        InputStreamReader ir = new InputStreamReader(pp.getInputStream());
        LineNumberReader input = new LineNumberReader(ir);
        for (; null != str; ) {
            str = input.readLine();
            if (str != null) {
                macSerial = str.trim();// 去空格
                break;
            }
        }
    } catch (IOException ex) {
        // 赋予默认值
        ex.printStackTrace();
    }
    return macSerial;
}
项目:incubator-netbeans    文件:MemoryFootprintTestCase.java   
/**
 * Get PID from the {xtest.workdir}/ide.pid file.
 *
 * @return
 */
private String getPID() {
    String xtestWorkdir = System.getProperty("xtest.workdir");

    if (xtestWorkdir == null) {
        fail("xtest.workdir property is not specified");
    }

    File ideRunning = new File(xtestWorkdir, "ide.pid");
    if (!ideRunning.exists()) {
        fail("Cannot find file containing PID of running IDE (" + ideRunning.getAbsolutePath());
    }

    try {
        LineNumberReader reader = new LineNumberReader(new FileReader(ideRunning));
        String pid = reader.readLine().trim();
        log("PID = " + pid);
        return pid;
    } catch (Exception exc) {
        exc.printStackTrace(getLog());
        fail("Exception rises when reading PID from ide.pid file");
    }
    return "";
}
项目:OpenDiabetes    文件:Result.java   
public static Result newSingleColumnStringResult(String colName,
        String contents) {

    Result result = Result.newSingleColumnResult(colName);
    LineNumberReader lnr =
        new LineNumberReader(new StringReader(contents));

    while (true) {
        String line = null;

        try {
            line = lnr.readLine();
        } catch (Exception e) {}

        if (line == null) {
            break;
        }

        result.getNavigator().add(new Object[]{ line });
    }

    return result;
}
项目:live_master    文件:SrtParser.java   
public static TextTrackImpl parse(InputStream is) throws IOException {
    LineNumberReader r = new LineNumberReader(new InputStreamReader(is, "UTF-8"));
    TextTrackImpl track = new TextTrackImpl();
    String numberString;
    while ((numberString = r.readLine()) != null) {
        String timeString = r.readLine();
        String lineString = "";
        String s;
        while (!((s = r.readLine()) == null || s.trim().equals(""))) {
            lineString += s + "\n";
        }

        long startTime = parse(timeString.split("-->")[0]);
        long endTime = parse(timeString.split("-->")[1]);

        track.getSubs().add(new TextTrackImpl.Line(startTime, endTime, lineString));

    }
    return track;
}
项目:sstore-soft    文件:Result.java   
public static Result newSingleColumnStringResult(String colName,
        String contents) {

    Result result = Result.newSingleColumnResult("OPERATION",
        Type.SQL_VARCHAR);
    LineNumberReader lnr =
        new LineNumberReader(new StringReader(contents));

    while (true) {
        String line = null;

        try {
            line = lnr.readLine();
        } catch (Exception e) {}

        if (line == null) {
            break;
        }

        result.getNavigator().add(new Object[]{ line });
    }

    return result;
}
项目:cornerstone    文件:LinuxSocketInfo.java   
public static List<LinuxSocketInfo> getSockets(String type) throws FileNotFoundException {
    final String jvmName = ManagementFactory.getRuntimeMXBean().getName();
    final int index = jvmName.indexOf('@');
    String pid = (jvmName.substring(0, index));
    ArrayList<LinuxSocketInfo> sockets = new ArrayList<>();
    String line;

    try(FileReader tcp = new FileReader("/proc/" + pid + "/net/"+type);LineNumberReader lnr = new LineNumberReader(tcp)) {
        lnr.readLine();
        while ((line=lnr.readLine())!=null) {
            LinuxSocketInfo socketInfo =parseSocket(line.trim(),type);
            sockets.add(socketInfo);
        }
    } catch (Throwable e) {
        _logger.warn("read linux tcp file failed",e);
    }
    return sockets;
}
项目:kafka-connect-fs    文件:TextFileReader.java   
@Override
public void seek(Offset offset) {
    if (offset.getRecordOffset() < 0) {
        throw new IllegalArgumentException("Record offset must be greater than 0");
    }
    try {
        if (offset.getRecordOffset() < reader.getLineNumber()) {
            this.reader = new LineNumberReader(new InputStreamReader(getFs().open(getFilePath())));
            currentLine = null;
        }
        while ((currentLine = reader.readLine()) != null) {
            if (reader.getLineNumber() - 1 == offset.getRecordOffset()) {
                this.offset.setOffset(reader.getLineNumber());
                return;
            }
        }
        this.offset.setOffset(reader.getLineNumber());
    } catch (IOException ioe) {
        throw new ConnectException("Error seeking file " + getFilePath(), ioe);
    }
}
项目:xproject    文件:NetUtils.java   
/**
 * 根据ip地址获取mac地址
 * @param ip
 * @return
 */
public String getMACAddress(String ip) {  
       String str = "";  
       String macAddress = "";  
       try {  
           Process p = Runtime.getRuntime().exec("nbtstat -A " + ip);  
           InputStreamReader ir = new InputStreamReader(p.getInputStream());  
           LineNumberReader input = new LineNumberReader(ir);  
           for (int i = 1; i < 100; i++) {  
               str = input.readLine();  
               if (str != null) {  
                   if (str.indexOf("MAC Address") > 1) {  
                       macAddress = str.substring(  
                               str.indexOf("MAC Address") + 14, str.length());  
                       break;  
                   }  
               }  
           }  
       } catch (IOException e) {  
           e.printStackTrace();  
       }  
       return macAddress;  
   }
项目:TestChat    文件:CrashHandler.java   
private String getStringFromFile(String error) {
        try {
                File file=new File(error);
                BufferedReader bufferedReader=new BufferedReader(new FileReader(file));
                LineNumberReader lineNumberReader=new LineNumberReader(bufferedReader);
                StringBuilder stringBuilder=new StringBuilder();
                String line;
                while ((line = lineNumberReader.readLine()) != null) {
                        stringBuilder.append(line).append("\n");
                }
                return stringBuilder.toString();
        } catch (IOException e) {
                e.printStackTrace();
                LogUtil.e("从文件中获取信息失败"+e.getMessage());
        }
        return null;
}
项目:neoscada    文件:ResourceDiscoverer.java   
private void performLoad ( final Reader stream )
{
    final Set<ConnectionDescriptor> result = new HashSet<ConnectionDescriptor> ();
    final LineNumberReader reader = new LineNumberReader ( stream );
    String line;
    try
    {
        while ( ( line = reader.readLine () ) != null )
        {
            final ConnectionDescriptor info = convert ( line );
            if ( info != null )
            {
                result.add ( info );
            }
        }
    }
    catch ( final IOException e )
    {
    }

    setConnections ( result );
}
项目:neoscada    文件:Transform.java   
/**
 * convert a Throwable into an array of Strings
 * @param throwable
 * @return string representation of the throwable
 */
public static String[] getThrowableStrRep(Throwable throwable) {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    throwable.printStackTrace(pw);
    pw.flush();
    LineNumberReader reader = new LineNumberReader(new StringReader(sw.toString()));
    ArrayList<String> lines = new ArrayList<String>();
    try {
        String line = reader.readLine();
        while (line != null) {
            lines.add(line);
            line = reader.readLine();
        }
    } catch (IOException ex) {
        lines.add(ex.toString());
    }
    String[] rep = new String[lines.size()];
    lines.toArray(rep);
    return rep;
}
项目:openjdk-jdk10    文件:J2DBench.java   
public static String loadOptions(FileReader fr, String filename) {
    LineNumberReader lnr = new LineNumberReader(fr);
    Group.restoreAllDefaults();
    String line;
    try {
        while ((line = lnr.readLine()) != null) {
            String reason = Group.root.setOption(line);
            if (reason != null) {
                System.err.println("Option "+line+
                                   " at line "+lnr.getLineNumber()+
                                   " ignored: "+reason);
            }
        }
    } catch (IOException e) {
        Group.restoreAllDefaults();
        return ("IO Error reading "+filename+
                " at line "+lnr.getLineNumber());
    }
    return null;
}
项目:mp4parser_android    文件:SrtParser.java   
public static TextTrackImpl parse(InputStream is) throws IOException {
    LineNumberReader r = new LineNumberReader(new InputStreamReader(is, "UTF-8"));
    TextTrackImpl track = new TextTrackImpl();
    String numberString;
    while ((numberString = r.readLine()) != null) {
        String timeString = r.readLine();
        String lineString = "";
        String s;
        while (!((s = r.readLine()) == null || s.trim().equals(""))) {
            lineString += s + "\n";
        }

        long startTime = parse(timeString.split("-->")[0]);
        long endTime = parse(timeString.split("-->")[1]);

        track.getSubs().add(new TextTrackImpl.Line(startTime, endTime, lineString));

    }
    return track;
}
项目:Android-Serial-Port    文件:SerialPortFinder.java   
private Vector<Driver> getDrivers() throws IOException {
    if (mDrivers == null) {
        mDrivers = new Vector<>();
        LineNumberReader r = new LineNumberReader(new FileReader("/proc/tty/drivers"));
        String line;
        while ((line = r.readLine()) != null) {
            // 设备名称可能存在空格
            // we do not extract driver name with split() 21
            String drivername = line.substring(0, 0x15).trim();
            String[] w = line.split(" +");
            if ((w.length >= 5) && ("serial".equals(w[w.length - 1]))) {
                mDrivers.add(new Driver(drivername, w[w.length - 4]));
            }
        }
        r.close();
    }
    return mDrivers;
}
项目:personium-core    文件:SnapshotFile.java   
/**
 * Count and return data pjson line.
 * @return Total line number
 */
public long countDataPJson() {
    Path pathInZip = pathMap.get(DATA_PJSON);
    try (BufferedReader bufReader = Files.newBufferedReader(pathInZip, Charsets.UTF_8)) {
        LineNumberReader reader = new LineNumberReader(bufReader);
        while (true) {
            long readByte = reader.skip(SKIP_DATA_NUM);
            if (readByte == 0) {
                break;
            }
        }
        return reader.getLineNumber();
    } catch (IOException e) {
        throw PersoniumCoreException.Common.FILE_IO_ERROR.params("read data pjson from snapshot file").reason(e);
    }
}
项目:Android-SerialPort-API    文件:SerialPortFinder.java   
Vector<Driver> getDrivers() throws IOException {
    if (mDrivers == null) {
        mDrivers = new Vector<Driver>();
        LineNumberReader r = new LineNumberReader(new FileReader("/proc/tty/drivers"));
        String l;
        while ((l = r.readLine()) != null) {
            // Issue 3:
            // Since driver name may contain spaces, we do not extract driver name with split()
            String drivername = l.substring(0, 0x15).trim();
            String[] w = l.split(" +");
            if ((w.length >= 5) && (w[w.length - 1].equals("serial"))) {
                Log.d(TAG, "Found new driver " + drivername + " on " + w[w.length - 4]);
                mDrivers.add(new Driver(drivername, w[w.length - 4]));
            }
        }
        r.close();
    }
    return mDrivers;
}
项目:Android-SerialPort-API    文件:SerialPortFinder.java   
Vector<Driver> getDrivers() throws IOException {
    if (mDrivers == null) {
        mDrivers = new Vector<Driver>();
        LineNumberReader r = new LineNumberReader(new FileReader("/proc/tty/drivers"));
        String l;
        while ((l = r.readLine()) != null) {
            // Issue 3:
            // Since driver name may contain spaces, we do not extract driver name with split()
            String drivername = l.substring(0, 0x15).trim();
            String[] w = l.split(" +");
            if ((w.length >= 5) && (w[w.length - 1].equals("serial"))) {
                Log.d(TAG, "Found new driver " + drivername + " on " + w[w.length - 4]);
                mDrivers.add(new Driver(drivername, w[w.length - 4]));
            }
        }
        r.close();
    }
    return mDrivers;
}
项目:s-store    文件:Result.java   
public static Result newSingleColumnStringResult(String colName,
        String contents) {

    Result result = Result.newSingleColumnResult("OPERATION",
        Type.SQL_VARCHAR);
    LineNumberReader lnr =
        new LineNumberReader(new StringReader(contents));

    while (true) {
        String line = null;

        try {
            line = lnr.readLine();
        } catch (Exception e) {}

        if (line == null) {
            break;
        }

        result.getNavigator().add(new Object[]{ line });
    }

    return result;
}
项目:lams    文件:ScriptUtils.java   
/**
 * Read a script from the provided {@code LineNumberReader}, using the supplied
 * comment prefix and statement separator, and build a {@code String} containing
 * the lines.
 * <p>Lines <em>beginning</em> with the comment prefix are excluded from the
 * results; however, line comments anywhere else &mdash; for example, within
 * a statement &mdash; will be included in the results.
 * @param lineNumberReader the {@code LineNumberReader} containing the script
 * to be processed
 * @param commentPrefix the prefix that identifies comments in the SQL script &mdash;
 * typically "--"
 * @param separator the statement separator in the SQL script &mdash; typically ";"
 * @return a {@code String} containing the script lines
 * @throws IOException in case of I/O errors
 */
public static String readScript(LineNumberReader lineNumberReader, String commentPrefix, String separator)
        throws IOException {
    String currentStatement = lineNumberReader.readLine();
    StringBuilder scriptBuilder = new StringBuilder();
    while (currentStatement != null) {
        if (commentPrefix != null && !currentStatement.startsWith(commentPrefix)) {
            if (scriptBuilder.length() > 0) {
                scriptBuilder.append('\n');
            }
            scriptBuilder.append(currentStatement);
        }
        currentStatement = lineNumberReader.readLine();
    }
    appendSeparatorToScriptIfNecessary(scriptBuilder, separator);
    return scriptBuilder.toString();
}
项目:docker-network-veth    文件:DumpSocat.java   
public static void main(String[] args) throws IOException {

        final byte[] bytes2 = Base64.getDecoder().decode("YnsLfVSN");
        System.out.println(new HexBinaryAdapter().marshal(bytes2));
        if(true) {
            return;
        }

        String filename = "/Users/esinev/Library/Preferences/IdeaIC15/scratches/docker-create-endpoint.txt";
        LineNumberReader reader = new LineNumberReader(new FileReader(filename));
        String line;
        while (( line = reader.readLine()) != null) {
//            System.out.println(line);
            if(line.length() >= 50 && line.charAt(48) == ' ' && line.charAt(49) == ' ') {
                String hex = line.substring(0, 49);
                final byte[] bytes = new HexBinaryAdapter().unmarshal(hex.replace(" ", ""));
                String value = new String(bytes);
                System.out.print(value);
//                line = line.substring(50);
            }  else {
                System.out.println(line);
            }
//            System.out.println(line);
        }
    }
项目:enhanced-vnc-thumbnail-viewer    文件:StdXMLReader.java   
/**
 * Initializes the XML reader.
 *
 * @param stream the input for the XML data.
 *
 * @throws java.io.IOException
 *      if an I/O error occurred
 */
public StdXMLReader(InputStream stream)
   throws IOException
{
   PushbackInputStream pbstream = new PushbackInputStream(stream);
   StringBuffer charsRead = new StringBuffer();
   Reader reader = this.stream2reader(stream, charsRead);
   this.currentReader = new StackedReader();
   this.readers = new Stack();
   this.currentReader.lineReader = new LineNumberReader(reader);
   this.currentReader.pbReader
      = new PushbackReader(this.currentReader.lineReader, 2);
   this.currentReader.publicId = "";

   try {
      this.currentReader.systemId = new URL("file:.");
   } catch (MalformedURLException e) {
      // never happens
   }

   this.startNewStream(new StringReader(charsRead.toString()));
}
项目:lams    文件:RSLPStemmerBase.java   
/**
 * Parse a resource file into an RSLP stemmer description.
 * @return a Map containing the named Steps in this description.
 */
protected static Map<String,Step> parse(Class<? extends RSLPStemmerBase> clazz, String resource) {
  // TODO: this parser is ugly, but works. use a jflex grammar instead.
  try {
    InputStream is = clazz.getResourceAsStream(resource);
    LineNumberReader r = new LineNumberReader(new InputStreamReader(is, StandardCharsets.UTF_8));
    Map<String,Step> steps = new HashMap<>();
    String step;
    while ((step = readLine(r)) != null) {
      Step s = parseStep(r, step);
      steps.put(s.name, s);
    }
    r.close();
    return steps;
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
项目:openjdk-jdk10    文件:Lines.java   
public void testPartialReadAndLineNo() throws IOException {
    MockLineReader r = new MockLineReader(5);
    LineNumberReader lr = new LineNumberReader(r);
    char[] buf = new char[5];
    lr.read(buf, 0, 5);
    assertEquals(0, lr.getLineNumber(), "LineNumberReader start with line 0");
    assertEquals(1, r.getLineNumber(), "MockLineReader start with line 1");
    assertEquals(new String(buf), "Line ");
    String l1 = lr.readLine();
    assertEquals(l1, "1", "Remaining of the first line");
    assertEquals(1, lr.getLineNumber(), "Line 1 is read");
    assertEquals(1, r.getLineNumber(), "MockLineReader not yet go next line");
    lr.read(buf, 0, 4);
    assertEquals(1, lr.getLineNumber(), "In the middle of line 2");
    assertEquals(new String(buf, 0, 4), "Line");
    ArrayList<String> ar = lr.lines()
         .peek(l -> assertEquals(lr.getLineNumber(), r.getLineNumber()))
         .collect(ArrayList::new, ArrayList::add, ArrayList::addAll);
    assertEquals(ar.get(0), " 2", "Remaining in the second line");
    for (int i = 1; i < ar.size(); i++) {
        assertEquals(ar.get(i), "Line " + (i + 2), "Rest are full lines");
    }
}
项目:javaide    文件:GPL.java   
/**
 * Prints out a note about the GPL if ProGuard is linked against unknown
 * code.
 */
public static void check()
{
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    new Exception().printStackTrace(new PrintStream(out));
    LineNumberReader reader = new LineNumberReader(
                              new InputStreamReader(
                              new ByteArrayInputStream(out.toByteArray())));

    Set unknownPackageNames = unknownPackageNames(reader);

    if (unknownPackageNames.size() > 0)
    {
        String uniquePackageNames = uniquePackageNames(unknownPackageNames);

        System.out.println("ProGuard is released under the GNU General Public License. You therefore");
        System.out.println("must ensure that programs that link to it ("+uniquePackageNames+"...)");
        System.out.println("carry the GNU General Public License as well. Alternatively, you can");
        System.out.println("apply for an exception with the author of ProGuard.");
    }
}
项目:jaer    文件:FordVIVisualizer.java   
private long parseDataStartTimeFromAeDatFile(AEFileInputStream aeis) throws FileNotFoundException, IOException {
    // # DataStartTime: System.currentTimeMillis() 1481800498468
    File f = aeis.getFile();
    LineNumberReader is = new LineNumberReader(new InputStreamReader(new FileInputStream(f)));
    while (is.getLineNumber() < 5000) {
        String line = is.readLine();
        if (line.contains("DataStartTime")) {
            Scanner s = new Scanner(line);
            s.next();
            s.next();
            s.next();
            aeDatStartTimeMs = s.nextLong();
            return aeDatStartTimeMs;
        }
    }
    log.warning("could not find data start time DataStartTime in AEDAT file");
    return -1;
}
项目:zencash-swing-wallet-ui    文件:Util.java   
public static JsonObject getJsonErrorMessage(String info)
    throws IOException
{
    JsonObject jInfo = new JsonObject();

    // Error message here comes from ZCash 1.0.7+ and is like:
    //zcash-cli getinfo
    //error code: -28
    //error message:
    //Loading block index...
    LineNumberReader lnr = new LineNumberReader(new StringReader(info));
    int errCode =  Integer.parseInt(lnr.readLine().substring(11).trim());
    jInfo.set("code", errCode);
    lnr.readLine();
    jInfo.set("message", lnr.readLine().trim());

    return jInfo;
}
项目:GongXianSheng    文件:CommonUtils.java   
/**
 * 通过Wifi获取MAC ADDRESS作为DEVICE ID
 * 缺点:如果Wifi关闭的时候,硬件设备可能无法返回MAC ADDRESS.。
 * @return
 */
public static String getMacAddress() {
    String macSerial = null;
    String str = "";
    try {
        Process pp = Runtime.getRuntime().exec("cat /sys/class/net/wlan0/address ");
        InputStreamReader ir = new InputStreamReader(pp.getInputStream());
        LineNumberReader input = new LineNumberReader(ir);

        for (; null != str;) {
            str = input.readLine();
            if (str != null) {
                macSerial = str.trim();// 去空格
                break;
            }
        }
    } catch (IOException ex) {
        // 赋予默认值
        ex.printStackTrace();
    }
    return macSerial;
}
项目:dev-courses    文件:Result.java   
public static Result newSingleColumnStringResult(String colName,
        String contents) {

    Result result = Result.newSingleColumnResult(colName);
    LineNumberReader lnr =
        new LineNumberReader(new StringReader(contents));

    while (true) {
        String line = null;

        try {
            line = lnr.readLine();
        } catch (Exception e) {}

        if (line == null) {
            break;
        }

        result.getNavigator().add(new Object[]{ line });
    }

    return result;
}
项目:komodoGUI    文件:Util.java   
public static JsonObject getJsonErrorMessage(String info)
    throws IOException
{
    JsonObject jInfo = new JsonObject();

    // Error message here comes from ZCash 1.0.7+ and is like:
    //zcash-cli getinfo
    //error code: -28
    //error message:
    //Loading block index...
    LineNumberReader lnr = new LineNumberReader(new StringReader(info));
    int errCode =  Integer.parseInt(lnr.readLine().substring(11).trim());
    jInfo.set("code", errCode);
    lnr.readLine();
    jInfo.set("message", lnr.readLine().trim());

    return jInfo;
}
项目:OpenJSharp    文件:J2DBench.java   
public static String loadOptions(FileReader fr, String filename) {
    LineNumberReader lnr = new LineNumberReader(fr);
    Group.restoreAllDefaults();
    String line;
    try {
        while ((line = lnr.readLine()) != null) {
            String reason = Group.root.setOption(line);
            if (reason != null) {
                System.err.println("Option "+line+
                                   " at line "+lnr.getLineNumber()+
                                   " ignored: "+reason);
            }
        }
    } catch (IOException e) {
        Group.restoreAllDefaults();
        return ("IO Error reading "+filename+
                " at line "+lnr.getLineNumber());
    }
    return null;
}
项目:jdk8u-jdk    文件:J2DBench.java   
public static String loadOptions(FileReader fr, String filename) {
    LineNumberReader lnr = new LineNumberReader(fr);
    Group.restoreAllDefaults();
    String line;
    try {
        while ((line = lnr.readLine()) != null) {
            String reason = Group.root.setOption(line);
            if (reason != null) {
                System.err.println("Option "+line+
                                   " at line "+lnr.getLineNumber()+
                                   " ignored: "+reason);
            }
        }
    } catch (IOException e) {
        Group.restoreAllDefaults();
        return ("IO Error reading "+filename+
                " at line "+lnr.getLineNumber());
    }
    return null;
}
项目:wherehowsX    文件:CSVFileAnalyzer.java   
public List<String[]> getLineToData(Path path, int lineNo) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(fs.open(path)));
    LineNumberReader reader = new LineNumberReader(br);
    reader.setLineNumber(lineNo);
    String str = "";
    List<String[]> lls = new ArrayList<String[]>();
    if (lineNo == 1 && (str = reader.readLine()) != null) {
        if(str.indexOf(",")>0) {
            lls.add(str.split(","));
        }else{
            lls.add(str.split("\t"));
        }
        return lls;
    } else if (lineNo >= 2 && (str = reader.readLine()) != null) {
        while ((str = reader.readLine()) != null) {
            if(str.indexOf(",")>0) {
                lls.add(str.split(","));
            }else {
                lls.add(str.split("\t"));
            }
        }
        return lls;
    } else {
        System.out.println("This is a EMPTY File");
        return null;
    }
}
项目:incubator-netbeans    文件:HeapTest.java   
private void compareTextFiles(File goledFile, File outFile) throws IOException {
    InputStreamReader goldenIsr = new InputStreamReader(new FileInputStream(goledFile),"UTF-8");
    LineNumberReader goldenReader = new LineNumberReader(goldenIsr);
    InputStreamReader isr = new InputStreamReader(new FileInputStream(outFile),"UTF-8");
    LineNumberReader reader = new LineNumberReader(isr);
    String goldenLine = "";
    String line = "";

    while(goldenLine != null && goldenLine.equals(line)) {
        goldenLine = goldenReader.readLine();
        line = reader.readLine();
    }
    assertEquals("File "+goledFile.getAbsolutePath()+" and "+outFile.getAbsolutePath()+" differs on line "+goldenReader.getLineNumber(), goldenLine, line);
}
项目:OpenDiabetes    文件:LineGroupReader.java   
/**
 * Default constructor for TestUtil usage.
 * Sections start at lines beginning with any non-space character.
 * SQL comment lines are ignored.
 */
public LineGroupReader(LineNumberReader reader) {

    this.sectionContinuations = defaultContinuations;
    this.sectionStarts        = ValuePool.emptyStringArray;
    this.ignoredStarts        = defaultIgnoredStarts;
    this.reader               = reader;

    try {
        getSection();
    } catch (Exception e) {}
}
项目:OpenDiabetes    文件:LineGroupReader.java   
/**
 * Constructor for sections starting with specified strings.
 */
public LineGroupReader(LineNumberReader reader, String[] sectionStarts) {

    this.sectionStarts        = sectionStarts;
    this.sectionContinuations = ValuePool.emptyStringArray;
    this.ignoredStarts        = ValuePool.emptyStringArray;
    this.reader               = reader;

    try {
        getSection();
    } catch (Exception e) {}
}
项目:sstore-soft    文件:DDLCompiler.java   
DDLStatement getNextStatement(LineNumberReader reader, VoltCompiler compiler) throws VoltCompiler.VoltCompilerException {
    DDLStatement retval = new DDLStatement();

    try {
        String stmt = "";

        // skip over any empty lines to read first real line
        while (stmt.equals("") || stmt.startsWith("--")) {
            stmt = reader.readLine();
            if (stmt == null)
                return null;
            stmt = stmt.trim();
        }
        // record the line number
        retval.lineNo = reader.getLineNumber();

        // add all lines until one ends with a semicolon
        while ((stmt.endsWith(";") == false) && (stmt.endsWith(";\n") == false)) {
            String newline = reader.readLine();
            if (newline == null) {
                String msg = "Schema file ended mid statment (no semicolon found)";
                throw compiler.new VoltCompilerException(msg, retval.lineNo);
            }
            newline = newline.trim();
            if (newline.equals(""))
                continue;
            if (newline.startsWith("--"))
                continue;
            stmt += newline + "\n";
        }

        retval.statement = stmt;

    } catch (IOException e) {
        throw compiler.new VoltCompilerException("Unable to read from file");
    }

    return retval;
}
项目:sstore-soft    文件:LineGroupReader.java   
/**
 * Default constructor for TestUtil usage.
 * Sections start at lines beginning with any non-space character.
 * SQL comment lines are ignored.
 */
public LineGroupReader(LineNumberReader reader) {

    this.sectionContinuations = defaultContinuations;
    this.sectionStarts        = ValuePool.emptyStringArray;
    this.ignoredStarts        = defaultIgnoredStarts;
    this.reader               = reader;

    try {
        getSection();
    } catch (Exception e) {}
}
项目:sstore-soft    文件:LineGroupReader.java   
/**
 * Constructor for sections starting with specified strings.
 */
public LineGroupReader(LineNumberReader reader, String[] sectionStarts) {

    this.sectionStarts        = sectionStarts;
    this.sectionContinuations = ValuePool.emptyStringArray;
    this.ignoredStarts        = ValuePool.emptyStringArray;
    this.reader               = reader;

    try {
        getSection();
    } catch (Exception e) {}
}
项目:sstore-soft    文件:TestJarReader.java   
/**
 *
 */
public void testReadFileFromJarfile() throws IOException {
    String catalog0 = this.catalog.serialize();
    assertTrue(catalog0.length() > 0);

    String catalog1 = JarReader.readFileFromJarfile(this.jarPath.getAbsolutePath(), CatalogUtil.CATALOG_FILENAME);
    assertTrue(catalog1.length() > 0);

    assertEquals(catalog0.length(), catalog1.length());

    LineNumberReader reader0 = new LineNumberReader(new CharArrayReader(catalog0.toCharArray()));
    LineNumberReader reader1 = new LineNumberReader(new CharArrayReader(catalog1.toCharArray()));

    try {
        int lines = 0;
        while (reader0.ready()) {
            assertEquals(reader0.ready(), reader1.ready());
            assertEquals(reader0.readLine(), reader1.readLine());
            lines++;
        }
        assertTrue(lines > 0);
        reader0.close();
        reader1.close();
    } catch (Exception ex) {
        ex.printStackTrace();
        assertTrue(false);
    }
}