@Override public List<String> asLines(String encoding) throws IOException { return delegate.asLines(encoding); }
@Override public List<String> asLines() throws IOException { return delegate.asLines(); }
/** Reads the full content of the file line by line with default * system encoding. Typical usage is * in <code>for</code> loops: * <pre> * for (String line : fo.asLines()) { * // do something * } * </pre> * <p> * The list is optimized for iterating line by line, other operations, * like accessing all the lines or counting the number of its lines may * be suboptimal. * * @return list of strings representing the content of the file * @exception IOException in case the content cannot be fully read * @since 7.21 */ public List<String> asLines() throws IOException { return asLines(Charset.defaultCharset().name()); }
String firstLine = ""; try { firstLine = sensorfile.asLines().get(lineNumber);
public List<String> diffLines(List<? extends CharSequence> ref, List<? extends CharSequence> pass) { CharSequence[] passLines = pass.toArray(new CharSequence[pass.size()]); CharSequence[] refLines = ref.toArray(new CharSequence[ref.size()]); //collect differences List<Result> results = findDifferences(passLines, refLines); //without differences it can be finished here if (results.isEmpty()) { return Collections.emptyList(); } //merge merge(results); //get print variant try { File tmpDiffFile = File.createTempFile("cnd_diff_lines", ".diff");// NOI18N printResults(passLines, refLines, results, tmpDiffFile); FileObject fo = FileUtil.toFileObject(tmpDiffFile); List<String> asLines = new ArrayList<>(fo.asLines()); try { tmpDiffFile.delete(); } catch (Exception e) { } return asLines; } catch (IOException e) { return Collections.singletonList("ERROR ON DIFF LINES " + e.getLocalizedMessage());// NOI18N } }
try (PrintWriter pw = new PrintWriter(foPrjDir.createAndOpen("nbactions.tmp"))) { if (isBoot2()) { for (String line : foNbAct.asLines()) { line = line.replace(ENV_RESTART_15, ENV_RESTART_20); line = line.replace("<run.", "<spring-boot.run."); for (String line : foNbAct.asLines()) { line = line.replace(ENV_RESTART_20, ENV_RESTART_15); line = line.replace("<spring-boot.run.", "<run.");
public static String foundProductName(CompilerFlavor compilerFlavor, ExecutionEnvironment ee, String path){ if (compilerFlavor.isSunStudioCompiler()) { FSPath fs = new FSPath(FileSystemProvider.getFileSystem(ee), path); FileObject fo = fs.getFileObject(); if (fo != null && fo.isValid()) { FileObject productName = fo.getFileObject("../LEGAL/ProductName"); //NOI18N if (productName != null && productName.isValid()) { try { List<String> asLines = productName.asLines(); if (asLines != null && asLines.size() > 0) { return asLines.get(0).trim(); } } catch (IOException ex) { ex.printStackTrace(System.err); } } } } return null; }
if (config.isValid() && config.canRead()) { try { Iterator<String> iterator = config.asLines().iterator(); while(iterator.hasNext()) { String line = iterator.next().trim();