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


Java LineNumberReader.readLine方法代码示例

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


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

示例1: 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 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(" +");
			Log.d("SerialPortFinder","drivername :"+drivername+"====="+l);
			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:HelloHuDi,项目名称:usb-with-serial-port,代码行数:21,代码来源:SerialPortFinder.java

示例2: 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

示例3: 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,项目名称:s-store,代码行数:25,代码来源:Result.java

示例4: 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

示例5: getLineCountInLogFile

import java.io.LineNumberReader; //导入方法依赖的package包/类
private int getLineCountInLogFile() {
    int linenumber = 0;

    if (_logFile.exists()) {
        try {
            FileReader fileReader = new FileReader(_logFile);

            LineNumberReader lineNumberReader = new LineNumberReader(fileReader);
            while (lineNumberReader.readLine() != null) {
                linenumber++;
            }
            lineNumberReader.close();

        } catch (IOException ioException) {
            ioException.printStackTrace();
        }
    }

    return linenumber;
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-AndroidApplication,代码行数:21,代码来源:Logger.java

示例6: readScript

import java.io.LineNumberReader; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:ScriptUtils.java

示例7: execLinuxCmd

import java.io.LineNumberReader; //导入方法依赖的package包/类
public static String execLinuxCmd(String cmd) {
    try {
        String[] cmdA = {"/bin/sh", "-c", cmd};
        Process process = Runtime.getRuntime().exec(cmdA);
        LineNumberReader br = new LineNumberReader(new InputStreamReader(
                process.getInputStream()));
        StringBuffer sb = new StringBuffer();
        String line;
        while ((line = br.readLine()) != null) {
            sb.append(line).append("\n");
        }
        br.close();
        process.getOutputStream().close(); // 不要忘记了一定要关
        return sb.toString();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:xjtushilei,项目名称:Webhooks,代码行数:20,代码来源:Cmd.java

示例8: execute

import java.io.LineNumberReader; //导入方法依赖的package包/类
/**
 * 执行Spark任务  TODD: Process的管理
 *
 * @param taskInfo
 * @return
 * @throws IOException
 */
public void execute(StonkTaskInfo taskInfo) throws IOException {
    ProcessBuilder pb = new ProcessBuilder();
    pb.directory(new File(systemConfig.getSparkK8sDir()));
    pb.command(buildCommand(taskInfo));
    Process p = pb.start();
    LineNumberReader reader = new LineNumberReader(new InputStreamReader(p.getInputStream()));
    String line = null;
    if ((line = reader.readLine()) != null) {
        System.out.println(line);
    }
}
 
开发者ID:hays2hong,项目名称:stonk,代码行数:19,代码来源:SparkTaskExecutor.java

示例9: copyfile

import java.io.LineNumberReader; //导入方法依赖的package包/类
private static void copyfile(File f) throws IOException {
	LineNumberReader reader = new LineNumberReader(new FileReader(f));
	String line = reader.readLine();
	while (line != null) {
		out.println(line);
		line = reader.readLine();
	}
	reader.close();
}
 
开发者ID:aserg-ufmg,项目名称:RefDiff,代码行数:10,代码来源:TyrubaDoc.java

示例10: compareTextFiles

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

示例11: getByCommand

import java.io.LineNumberReader; //导入方法依赖的package包/类
public static InetAddress[] getByCommand() {
    try {
        LineNumberReader lnr = new LineNumberReader(new InputStreamReader(Runtime.getRuntime
                ().exec("getprop").getInputStream()));
        ArrayList<InetAddress> servers = new ArrayList(5);
        while (true) {
            String line = lnr.readLine();
            if (line == null) {
                break;
            }
            int split = line.indexOf("]: [");
            if (split != -1) {
                String property = line.substring(1, split);
                String value = line.substring(split + 4, line.length() - 1);
                if (property.endsWith(".dns") || property.endsWith(".dns1") || property
                        .endsWith(".dns2") || property.endsWith(".dns3") || property.endsWith
                        (".dns4")) {
                    InetAddress ip = InetAddress.getByName(value);
                    if (ip != null) {
                        value = ip.getHostAddress();
                        if (!(value == null || value.length() == 0)) {
                            servers.add(ip);
                        }
                    }
                }
            }
        }
        if (servers.size() > 0) {
            return (InetAddress[]) servers.toArray(new InetAddress[servers.size()]);
        }
    } catch (IOException e) {
        Logger.getLogger("AndroidDnsServer").log(Level.WARNING, "Exception in findDNSByExec",
                e);
    }
    return null;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:37,代码来源:AndroidDnsServer.java

示例12: leesRegel

import java.io.LineNumberReader; //导入方法依赖的package包/类
private String leesRegel(LineNumberReader br, int regelnummer) {
    try {
        String regel = null;
        while (br.getLineNumber() <= regelnummer) {
            regel = br.readLine();
        }
        return regel;
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:12,代码来源:SteekproefServiceImpl.java

示例13: readMockParams

import java.io.LineNumberReader; //导入方法依赖的package包/类
private List<String> readMockParams() throws IOException {
  LinkedList<String> ret = new LinkedList<String>();
  LineNumberReader reader = new LineNumberReader(new FileReader(
      mockParamFile));
  String line;
  while((line = reader.readLine()) != null) {
    ret.add(line);
  }
  reader.close();
  return ret;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:TestLinuxContainerExecutorWithMocks.java

示例14: unknownPackageNames

import java.io.LineNumberReader; //导入方法依赖的package包/类
/**
 * Returns a set of package names from the given stack trace.
 */
private static Set unknownPackageNames(LineNumberReader reader)
{
    Set packageNames = new HashSet();

    try
    {
        while (true)
        {
            String line = reader.readLine();
            if (line == null)
            {
                break;
            }

            line = line.trim();
            if (line.startsWith("at "))
            {
                line = line.substring(2).trim();
                line = trimSuffix(line, '(');
                line = trimSuffix(line, '.');
                line = trimSuffix(line, '.');

                if (line.length() > 0 && !isKnown(line))
                {
                    packageNames.add(line);
                }
            }
        }
    }
    catch (IOException ex)
    {
        // We'll just stop looking for more names.
    }

    return packageNames;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:40,代码来源:GPL.java

示例15: testSeekForRwServer

import java.io.LineNumberReader; //导入方法依赖的package包/类
/**
 * Ensures that client seeks for r/w servers while it's connected to r/o
 * server.
 */
@SuppressWarnings("deprecation")
@Test(timeout = 90000)
public void testSeekForRwServer() throws Exception {
    // setup the logger to capture all logs
    Layout layout = Logger.getRootLogger().getAppender("CONSOLE")
            .getLayout();
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    WriterAppender appender = new WriterAppender(layout, os);
    appender.setImmediateFlush(true);
    appender.setThreshold(Level.INFO);
    Logger zlogger = Logger.getLogger("org.apache.zookeeper");
    zlogger.addAppender(appender);

    try {
        qu.shutdown(2);
        CountdownWatcher watcher = new CountdownWatcher();
        ZooKeeper zk = new ZooKeeper(qu.getConnString(),
                CONNECTION_TIMEOUT, watcher, true);
        watcher.waitForConnected(CONNECTION_TIMEOUT);

        // if we don't suspend a peer it will rejoin a quorum
        qu.getPeer(1).peer.suspend();

        // start two servers to form a quorum; client should detect this and
        // connect to one of them
        watcher.reset();
        qu.start(2);
        qu.start(3);
        ClientBase.waitForServerUp(qu.getConnString(), 2000);
        watcher.waitForConnected(CONNECTION_TIMEOUT);
        zk.create("/test", "test".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE,
                CreateMode.PERSISTENT);

        // resume poor fellow
        qu.getPeer(1).peer.resume();
    } finally {
        zlogger.removeAppender(appender);
    }

    os.close();
    LineNumberReader r = new LineNumberReader(new StringReader(os
            .toString()));
    String line;
    Pattern p = Pattern.compile(".*Majority server found.*");
    boolean found = false;
    while ((line = r.readLine()) != null) {
        if (p.matcher(line).matches()) {
            found = true;
            break;
        }
    }
    Assert.assertTrue(
            "Majority server wasn't found while connected to r/o server",
            found);
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:60,代码来源:ReadOnlyModeTest.java


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