当前位置: 首页>>代码示例>>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;未经允许,请勿转载。