當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。