当前位置: 首页>>代码示例>>Java>>正文


Java LineNumberReader类代码示例

本文整理汇总了Java中java.io.LineNumberReader的典型用法代码示例。如果您正苦于以下问题:Java LineNumberReader类的具体用法?Java LineNumberReader怎么用?Java LineNumberReader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LineNumberReader类属于java.io包,在下文中一共展示了LineNumberReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDrivers

import java.io.LineNumberReader; //导入依赖的package包/类
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;
}
 
开发者ID:harveyandroid,项目名称:AndroidSerialPort,代码行数:20,代码来源:SerialPortFinder.java

示例2: getMac

import java.io.LineNumberReader; //导入依赖的package包/类
/**
 * 获取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;
}
 
开发者ID:wangzhaosheng,项目名称:publicProject,代码行数:24,代码来源:GlobalVariable.java

示例3: getPID

import java.io.LineNumberReader; //导入依赖的package包/类
/**
 * 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 "";
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:MemoryFootprintTestCase.java

示例4: newSingleColumnStringResult

import java.io.LineNumberReader; //导入依赖的package包/类
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;
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:24,代码来源:Result.java

示例5: parse

import java.io.LineNumberReader; //导入依赖的package包/类
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;
}
 
开发者ID:lisnstatic,项目名称:live_master,代码行数:21,代码来源:SrtParser.java

示例6: newSingleColumnStringResult

import java.io.LineNumberReader; //导入依赖的package包/类
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;
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:25,代码来源:Result.java

示例7: getSockets

import java.io.LineNumberReader; //导入依赖的package包/类
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;
}
 
开发者ID:ctripcorp,项目名称:cornerstone,代码行数:19,代码来源:LinuxSocketInfo.java

示例8: seek

import java.io.LineNumberReader; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:mmolimar,项目名称:kafka-connect-fs,代码行数:22,代码来源:TextFileReader.java

示例9: getMACAddress

import java.io.LineNumberReader; //导入依赖的package包/类
/**
 * 根据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;  
   }
 
开发者ID:penggle,项目名称:xproject,代码行数:28,代码来源:NetUtils.java

示例10: getStringFromFile

import java.io.LineNumberReader; //导入依赖的package包/类
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;
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:18,代码来源:CrashHandler.java

示例11: performLoad

import java.io.LineNumberReader; //导入依赖的package包/类
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 );
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:23,代码来源:ResourceDiscoverer.java

示例12: getThrowableStrRep

import java.io.LineNumberReader; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:26,代码来源:Transform.java

示例13: loadOptions

import java.io.LineNumberReader; //导入依赖的package包/类
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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:J2DBench.java

示例14: getDrivers

import java.io.LineNumberReader; //导入依赖的package包/类
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;
}
 
开发者ID:Rairmmd,项目名称:Android-Serial-Port,代码行数:19,代码来源:SerialPortFinder.java

示例15: countDataPJson

import java.io.LineNumberReader; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:personium,项目名称:personium-core,代码行数:20,代码来源:SnapshotFile.java


注:本文中的java.io.LineNumberReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。