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


Java LineNumberReader.close方法代码示例

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


在下文中一共展示了LineNumberReader.close方法的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: compareOutput

import java.io.LineNumberReader; //导入方法依赖的package包/类
protected boolean compareOutput(Reader expected, Reader actual) throws IOException {
    LineNumberReader expectedOutput = new LineNumberReader(expected);
    LineNumberReader actualOutput = new LineNumberReader(actual);

    while (expectedOutput.ready() && actualOutput.ready()) {
        String expectedLine = expectedOutput.readLine();
        String actualLine = actualOutput.readLine();
        if (!expectedLine.equals(actualLine)) {
            System.out.println("Entityreference expansion failed, line no: " + expectedOutput.getLineNumber());
            System.out.println("Expected: " + expectedLine);
            System.out.println("Actual  : " + actualLine);
            return false;
        }
    }
    expectedOutput.close();
    actualOutput.close();
    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:EntityTest.java

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

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

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

示例6: 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:licheedev,项目名称:Android-SerialPort-API,代码行数:20,代码来源:SerialPortFinder.java

示例7: append

import java.io.LineNumberReader; //导入方法依赖的package包/类
private void append(File stdout) throws Exception
{
    PrintWriter writer = new PrintWriter(new FileWriter(source2document(_sourceFile), true));

    writer.println("\n Standard output:\n");
    writer.println(CODE_BEGIN);
    LineNumberReader reader = new LineNumberReader(new FileReader(stdout));

    for (String line = reader.readLine(); line != null; line = reader.readLine())
    {
        writer.println(line);
    }

    writer.println(CODE_END);
    reader.close();
    writer.close();
}
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:18,代码来源:SampleRunnerTest.java

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

示例9: countLines

import java.io.LineNumberReader; //导入方法依赖的package包/类
public static long countLines(String filePath) throws Exception {
	LineNumberReader lnr = new LineNumberReader(new FileReader(new File(filePath)));
	try {
		lnr.skip(Long.MAX_VALUE);
		return lnr.getLineNumber() + 1;
	} finally {
		lnr.close();
	}
}
 
开发者ID:tedhtchang,项目名称:JanusGraphBench,代码行数:10,代码来源:BatchHelper.java

示例10: getStoredResults

import java.io.LineNumberReader; //导入方法依赖的package包/类
public static StoredResult[] getStoredResults(File registerFile, boolean addDir) {
    try {
        LineNumberReader reader = new LineNumberReader(new FileReader(registerFile));

        StoredResult[] list = null;
        String line = null;
        String directory = null;
        String description = null;
        int count = 0;
        while ((line = reader.readLine()) != null) {
            if (line.startsWith("Iteration ")) {
                description = line;
                count ++;
                StoredResult[] newList = new StoredResult[count];
                for (int i = 0; i < count-1; i ++) {
                    newList[i] = list[i];
                }
                newList[count-1] = new StoredResult(directory, description, addDir);
                list = newList;
            } else {
                directory = line;
            }
        }

        reader.close();
        if (list == null) {
            list = new StoredResult[0];
        }
        return list;
    } catch (IOException e) {
        return new StoredResult[0];
    }
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:34,代码来源:StoredResult.java

示例11: testReadFileFromJarfile

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

示例12: parse

import java.io.LineNumberReader; //导入方法依赖的package包/类
@Override
public void parse(Reader in) throws IOException, ParseException {
  LineNumberReader br = new LineNumberReader(in);
  try {
    String line = null;
    String lastSynSetID = "";
    CharsRef synset[] = new CharsRef[8];
    int synsetSize = 0;
    
    while ((line = br.readLine()) != null) {
      String synSetID = line.substring(2, 11);

      if (!synSetID.equals(lastSynSetID)) {
        addInternal(synset, synsetSize);
        synsetSize = 0;
      }

      if (synset.length <= synsetSize+1) {
        synset = Arrays.copyOf(synset, synset.length * 2);
      }
      
      synset[synsetSize] = parseSynonym(line, new CharsRefBuilder());
      synsetSize++;
      lastSynSetID = synSetID;
    }
    
    // final synset in the file
    addInternal(synset, synsetSize);
  } catch (IllegalArgumentException e) {
    ParseException ex = new ParseException("Invalid synonym rule at line " + br.getLineNumber(), 0);
    ex.initCause(e);
    throw ex;
  } finally {
    br.close();
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:37,代码来源:WordnetSynonymParser.java

示例13: parse

import java.io.LineNumberReader; //导入方法依赖的package包/类
@Override
public void parse(Reader in) throws IOException, ParseException {
  LineNumberReader br = new LineNumberReader(in);
  try {
    addInternal(br);
  } catch (IllegalArgumentException e) {
    ParseException ex = new ParseException("Invalid synonym rule at line " + br.getLineNumber(), 0);
    ex.initCause(e);
    throw ex;
  } finally {
    br.close();
  }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:SolrSynonymParser.java

示例14: diff

import java.io.LineNumberReader; //导入方法依赖的package包/类
/**
 * @param refFile first file to compare -- ref
 * @param passFile second file to compare -- golden
 * @param diffFile difference file, caller can pass null value, when results are not needed.
 * @return true iff files differ
 */
public boolean diff(File refFile,File passFile,File diffFile) throws IOException {
    LineNumberReader first = new LineNumberReader(new FileReader(refFile));
    LineNumberReader second = new LineNumberReader(new FileReader(passFile));
    String line;
    
    String[] refLines, passLines;
    
    //read golden file
    List<String> tmp = new ArrayList<String>(64);
    while ((line = second.readLine()) != null) {
        if (ignoreEmptyLines && line.trim().length() == 0) {
            continue;
        }
        tmp.add(line);
    }
    passLines = tmp.toArray(new String[tmp.size()]);
    tmp.clear();
    second.close();
    //read ref file
    tmp = new ArrayList<String>(64);
    while ((line = first.readLine()) != null) {
        if (ignoreEmptyLines && line.trim().length() == 0) {
            continue;
        }
        tmp.add(line);
    }
    refLines = tmp.toArray(new String[tmp.size()]);
    tmp.clear();
    first.close();
    //collect differences
    List<Result> results = findDifferences(passLines, refLines);
    //without differences it can be finished here
    if (results.size() == 0) return false;
    if (diffFile == null) return results.size() > 0;
    //merge
    merge(results);
    //print
    printResults(passLines, refLines, results, diffFile);
    return results.size() > 0;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:47,代码来源:LineDiff.java

示例15: getFileLines

import java.io.LineNumberReader; //导入方法依赖的package包/类
static Vector getFileLines(File f) throws IOException {

        LineNumberReader read = new LineNumberReader(new FileReader(f));
        Vector           v    = new Vector();

        for (;;) {
            String line = read.readLine();

            if (line == null) {
                break;
            }

            v.addElement(line);
        }

        read.close();

        return v;
    }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:20,代码来源:CodeSwitcher.java


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