當前位置: 首頁>>代碼示例>>Java>>正文


Java LineIterator.nextLine方法代碼示例

本文整理匯總了Java中org.apache.commons.io.LineIterator.nextLine方法的典型用法代碼示例。如果您正苦於以下問題:Java LineIterator.nextLine方法的具體用法?Java LineIterator.nextLine怎麽用?Java LineIterator.nextLine使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.io.LineIterator的用法示例。


在下文中一共展示了LineIterator.nextLine方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isSearchTextPresentInLinesOfFile

import org.apache.commons.io.LineIterator; //導入方法依賴的package包/類
private boolean isSearchTextPresentInLinesOfFile(File f) {
    LineIterator it = null;
    try {
        it = FileUtils.lineIterator(f, "UTF-8");
        while (it.hasNext()) {
            String line = it.nextLine();
            if (line.contains(searchText)) {
                return true;
            }
        }
        return false;
    } catch (IOException e) {
        throw new RuntimeException(e);
    } finally {
        LineIterator.closeQuietly(it);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:18,代碼來源:FileSearchMatcher.java

示例2: realizarCargaArquivo

import org.apache.commons.io.LineIterator; //導入方法依賴的package包/類
public void realizarCargaArquivo() {
	ClassLoader classLoader = getClass().getClassLoader();
	File file = new File(classLoader.getResource(NOME_ARQUIVO).getFile());
	LineIterator it = null;
	try {
		it = FileUtils.lineIterator(file, "UTF-8");
		while(it.hasNext()) {
			String linha = it.nextLine();
			String[] dados = linha.split("\\|");
			inserirCliente(dados[0], dados[1], dados[2], dados[3], dados[4],
					dados[5], dados[6], dados[7], dados[8], dados[9]);
		}
	} catch (Exception e) {
		e.printStackTrace();
	} finally {
		it.close();
	}
}
 
開發者ID:rhawan,項目名稱:microservices-tcc-alfa,代碼行數:19,代碼來源:CargaCliente.java

示例3: realizarCargaArquivo

import org.apache.commons.io.LineIterator; //導入方法依賴的package包/類
public void realizarCargaArquivo() {
	ClassLoader classLoader = getClass().getClassLoader();
	File file = new File(classLoader.getResource(NOME_ARQUIVO).getFile());
	LineIterator it = null;
	try {
		it = FileUtils.lineIterator(file, "UTF-8");
		while(it.hasNext()) {
			String linha = it.nextLine();
			String[] dados = linha.split("\\|");
			inserirItemAvaliado(dados[0], dados[1], dados[2], dados[3], dados[4]);
		}
	} catch (Exception e) {
		e.printStackTrace();
	} finally {
		it.close();
	}
}
 
開發者ID:rhawan,項目名稱:microservices-tcc-alfa,代碼行數:18,代碼來源:CargaProduto.java

示例4: fileToCodeList

import org.apache.commons.io.LineIterator; //導入方法依賴的package包/類
public static List<Code> fileToCodeList(String fileName) {

		List<Code> codes = new ArrayList<>();
		try {
			LineIterator it = getLineIterator(fileName);
			while (it.hasNext()) {
				String line = it.nextLine();
				if (line.equals("") || line.startsWith("#"))
					continue;
				String[] parts = line.split(";", 2);
				codes.add((new Code(parts[0], parts[1])));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

		return codes;

	}
 
開發者ID:pkiraly,項目名稱:metadata-qa-marc,代碼行數:20,代碼來源:CodeFileReader.java

示例5: converteerAfnemerindicatiebestand

import org.apache.commons.io.LineIterator; //導入方法依賴的package包/類
private void converteerAfnemerindicatiebestand(final long maxAfnemerindicatieId,
                                               final OutputStream os, final LineIterator it) throws IOException {
    long voortgang = 0;
    final Map<Short, Short> partijConversieMap = partijConversie.getPartijConversieMap();
    final Map<Integer, Integer> leveringsautorisatieConversieMap = leveringsautorisatieConversie.getLeveringsautorisatieConversieMap();
    while (it.hasNext()) {
        final String line = it.nextLine();
        final String[] splitLine = StringUtils.split(line, ",");
        final long origId = Long.parseLong(splitLine[0]);
        final long id = maxAfnemerindicatieId + origId;
        final String pers = splitLine[1];
        final String afnemer = String.valueOf(partijConversieMap.get(Short.parseShort(splitLine[2])));
        final String levsautorisatie = String.valueOf(leveringsautorisatieConversieMap.get(Integer.parseInt(splitLine[3])));
        final String dataanvmaterieleperiode = StringUtils.defaultString(StringUtils.trimToNull(splitLine[4]), NULL_VALUE);
        final String dateindevolgen = StringUtils.defaultString(StringUtils.trimToNull(splitLine[5]), NULL_VALUE);
        final String indag = splitLine[6];
        final String newLine = String.format("%s,%s,%s,%s,%s,%s,%s%n", id, pers, afnemer, levsautorisatie,
                dataanvmaterieleperiode, dateindevolgen, indag);
        IOUtils.write(newLine, os, StandardCharsets.UTF_8);

        voortgang++;
        if (voortgang % LOG_TRESHOLD == 0) {
            LOGGER.info("Voortgang persafnemerindicatie {}", voortgang);
        }
    }
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:27,代碼來源:AfnemerindicatieConversie.java

示例6: run

import org.apache.commons.io.LineIterator; //導入方法依賴的package包/類
@Override
public void run() {
	LineIterator it = null;

	try {
		it = IOUtils.lineIterator(inputStream, "UTF-8");

		while (it.hasNext()) {
			String line = it.nextLine();
			LOGGER.debug(line);
			if (filtered) {
				filtered = filter(line);
			}
		}
	} catch (IOException ioe) {
		LOGGER.debug("Error consuming input stream: {}", ioe.getMessage());
	} catch (IllegalStateException ise) {
		LOGGER.debug("Error reading from closed input stream: {}", ise.getMessage());
	} finally {
		LineIterator.closeQuietly(it); // clean up all associated resources
	}
}
 
開發者ID:DigitalMediaServer,項目名稱:DigitalMediaServer,代碼行數:23,代碼來源:OutputTextLogger.java

示例7: loadFields

import org.apache.commons.io.LineIterator; //導入方法依賴的package包/類
private Set<String> loadFields() {
  Set<String> fields = Sets.newHashSet();
  LineIterator it;
  try {
    it = FileUtils.lineIterator(_fieldsFile);
  } catch (IOException ex) {
    throw new OpenGammaRuntimeException("IOException when reading " + _fieldsFile, ex);
  }
  try {
    while (it.hasNext()) {
      String line = it.nextLine();
      if (StringUtils.isBlank(line) || line.charAt(0) == '#') {
        continue;
      }
      fields.add(line);
    }
  } finally {
    LineIterator.closeQuietly(it);
  }
  return fields;
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:22,代碼來源:BloombergRefDataCollector.java

示例8: createInputFile

import org.apache.commons.io.LineIterator; //導入方法依賴的package包/類
public static void createInputFile(Configuration conf, Path file, Path targetFile,
                                   String startNode)
    throws IOException {
  FileSystem fs = file.getFileSystem(conf);

  OutputStream os = fs.create(targetFile);
  LineIterator iter = org.apache.commons.io.IOUtils
      .lineIterator(fs.open(file), "UTF8");
  while (iter.hasNext()) {
    String line = iter.nextLine();

    String[] parts = StringUtils.split(line);
    int distance = Node.INFINITE;
    if (startNode.equals(parts[0])) {
      distance = 0;
    }
    IOUtils.write(parts[0] + '\t' + String.valueOf(distance) + "\t\t",
        os);
    IOUtils.write(StringUtils.join(parts, '\t', 1, parts.length), os);
    IOUtils.write("\n", os);
  }

  os.close();
}
 
開發者ID:Hanmourang,項目名稱:hiped2,代碼行數:25,代碼來源:Main.java

示例9: createInputFile

import org.apache.commons.io.LineIterator; //導入方法依賴的package包/類
public static int createInputFile(Path file, Path targetFile)
    throws IOException {
  Configuration conf = new Configuration();
  FileSystem fs = file.getFileSystem(conf);

  int numNodes = getNumNodes(file);
  double initialPageRank = 1.0 / (double) numNodes;

  OutputStream os = fs.create(targetFile);
  LineIterator iter = IOUtils
      .lineIterator(fs.open(file), "UTF8");

  while (iter.hasNext()) {
    String line = iter.nextLine();

    String[] parts = StringUtils.split(line);

    Node node = new Node()
        .setPageRank(initialPageRank)
        .setAdjacentNodeNames(
            Arrays.copyOfRange(parts, 1, parts.length));
    IOUtils.write(parts[0] + '\t' + node.toString() + '\n', os);
  }
  os.close();
  return numNodes;
}
 
開發者ID:Hanmourang,項目名稱:hiped2,代碼行數:27,代碼來源:Main.java

示例10: getNext

import org.apache.commons.io.LineIterator; //導入方法依賴的package包/類
@Override
public void getNext(JCas aJcas) throws IOException, CollectionException {
	File f = documents.get(i);
	LineIterator it = FileUtils.lineIterator(f);
	int start =0;
	int inds=0;
	StringBuffer sb = new StringBuffer();
	while(it.hasNext()){
	    String line = it.nextLine();
	    Sentence sent = new Sentence(aJcas, start, start+line.length());
	    sent.addToIndexes();
	    start = start + line.length() + 1;
	    sb.append(line+"\n");
	    if (inds%10000==0)
	    	System.out.println("R"+inds);
	}
	aJcas.setDocumentText(sb.toString());
	//had to add english as default language, one could also add another configuration parameter
	aJcas.setDocumentLanguage("en");
	i++;
}
 
開發者ID:tudarmstadt-lt,項目名稱:sentiment,代碼行數:22,代碼來源:StanfordReader.java

示例11: readFrequentSequences

import org.apache.commons.io.LineIterator; //導入方法依賴的package包/類
/** Read in frequent sequences (sorted by support) */
public static SortedMap<Sequence, Integer> readFrequentSequences(final File output) throws IOException {
	final HashMap<Sequence, Integer> sequences = new HashMap<>();

	final LineIterator it = FileUtils.lineIterator(output);
	while (it.hasNext()) {
		final String line = it.nextLine();
		if (!line.trim().isEmpty()) {
			final String[] splitLine = line.split("#SUP:");
			final String[] items = splitLine[0].trim().split("-1");
			final Sequence seq = new Sequence();
			for (final String item : items)
				seq.add(Integer.parseInt(item.trim()));
			final int supp = Integer.parseInt(splitLine[1].trim());
			sequences.put(seq, supp);
		}
	}
	// Sort sequences by support
	final Ordering<Sequence> comparator = Ordering.natural().reverse().onResultOf(Functions.forMap(sequences))
			.compound(Ordering.usingToString());
	return ImmutableSortedMap.copyOf(sequences, comparator);
}
 
開發者ID:mast-group,項目名稱:sequence-mining,代碼行數:23,代碼來源:FrequentSequenceMining.java

示例12: createProjFile

import org.apache.commons.io.LineIterator; //導入方法依賴的package包/類
private void createProjFile(String file, String projectLabel) {
	File template = new File(FAQ_DIR+File.separator+"whc_template"+File.separator+"project.html");
	StringBuffer buf = new StringBuffer();
	String title = StringEscapeUtils.escapeHtml(projectLabel);
	LineIterator it = null;
	try {
		it = FileUtils.lineIterator(template, "UTF-8");
		try {
			while (it.hasNext()) {
				String line = it.nextLine();
				line = line.replaceAll("\\$title", title);
				buf.append(line+CRLF); 
			}
		} finally {
			it.close();
		}
	} catch (Exception e) {
		LOGGER.error("Can't copy project.html template file: " + e.getMessage());
	}
	writeFile(buf.toString(), file);
}
 
開發者ID:trackplus,項目名稱:Genji,代碼行數:22,代碼來源:FaqsDatasource.java

示例13: uploadFile

import org.apache.commons.io.LineIterator; //導入方法依賴的package包/類
public String uploadFile(String fileName) {
    File file = new File(getDataFolder(), fileName);
    if (!file.exists())
        return null;
    LineIterator it;
    String lines = "";
    try {
        it = FileUtils.lineIterator(file, "UTF-8");
        try {
            while (it.hasNext()) {
                String line = it.nextLine();
                lines = lines + line + "\n";
            }
        } finally {
            it.close();
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return MCDebug.paste(fileName, lines);
}
 
開發者ID:ConnorLinfoot,項目名稱:CratesPlus,代碼行數:22,代碼來源:CratesPlus.java

示例14: readTransactions

import org.apache.commons.io.LineIterator; //導入方法依賴的package包/類
public static TransactionList readTransactions(final File inputFile) throws IOException {

		final List<Transaction> transactions = new ArrayList<>();

		// for each line (transaction) until the end of file
		final LineIterator it = FileUtils.lineIterator(inputFile, "UTF-8");
		while (it.hasNext()) {

			final String line = it.nextLine();
			// if the line is a comment, is empty or is a
			// kind of metadata
			if (line.isEmpty() == true || line.charAt(0) == '#' || line.charAt(0) == '%' || line.charAt(0) == '@') {
				continue;
			}

			// split the transaction into items
			final String[] lineSplited = line.split(" ");
			// convert to Transaction class and add it to the structure
			transactions.add(getTransaction(lineSplited));

		}
		// close the input file
		LineIterator.closeQuietly(it);

		return new TransactionList(transactions);
	}
 
開發者ID:mast-group,項目名稱:sequence-mining,代碼行數:27,代碼來源:SequenceMining.java

示例15: readSQSSequences

import org.apache.commons.io.LineIterator; //導入方法依賴的package包/類
/** Read in SQS sequences (sorted by worth) */
public static LinkedHashMap<Sequence, Double> readSQSSequences(final File output) throws IOException {
	final LinkedHashMap<Sequence, Double> sequences = new LinkedHashMap<>();

	final LineIterator it = FileUtils.lineIterator(output);
	while (it.hasNext()) {
		final String line = it.nextLine();
		if (!line.trim().isEmpty()) {
			final String[] splitLine = line.split("  ");
			final String[] items = splitLine[0].split(" ");
			final Sequence seq = new Sequence();
			for (final String item : items)
				seq.add(Integer.parseInt(item));
			final double worth = Double.parseDouble(splitLine[1].split(" ")[1]);
			sequences.put(seq, worth);
		}
	}

	return sequences;
}
 
開發者ID:mast-group,項目名稱:sequence-mining,代碼行數:21,代碼來源:StatisticalSequenceMining.java


注:本文中的org.apache.commons.io.LineIterator.nextLine方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。