Package org.apache.commons.io

Examples of org.apache.commons.io.LineIterator


    }

    @Override
    public List<String> getLines(String resource) throws IOException {
        List<String> lines = new ArrayList<String>();
        LineIterator it = IOUtils.lineIterator(openResource(resource), "UTF-8");
        while(it.hasNext()){
            String line = it.nextLine();
            if(line != null && !line.isEmpty() && line.charAt(0) != '#'){
                lines.add(line);
            }
        }
        return lines;
View Full Code Here


     * Expected to be called only during activation
     * @param in
     * @throws IOException
     */
    private void readPrefixMappings(InputStream in) throws IOException {
        LineIterator it = IOUtils.lineIterator(in, "UTF-8");
        while(it.hasNext()){
            String mapping = it.nextLine();
            if(mapping.charAt(0) != '#'){
                int sep = mapping.indexOf('\t');
                if(sep < 0 || mapping.length() <= sep+1){
                    log.warn("Illegal prefix mapping '{}'",mapping);
                } else {
View Full Code Here

    pw = pwi;
  }

  @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);
        }
      }
View Full Code Here

  public boolean readWebFilters(String filename) {
    PatternMap filter = null;
    String line;
    try {
      LineIterator it = FileUtils.lineIterator(new File(filename));
      try {
        while (it.hasNext()) {
          line = it.nextLine().trim();
          if (line.isEmpty() || line.startsWith("#")) {
            // continue
          } else if (line.equals("EXCLUDE")) {
            filter = excludes;
          } else if (line.equals("OPTIONS")) {
            filter = autoOptions;
          } else if (line.equals("REPLACE")) {
            filter = replacements;
          } else if (filter != null) {
            String[] var = line.split(" \\| ", 2);
            filter.add(var[0], var.length > 1 ? var[1] : null);
          }
        }
        return true;
      } finally {
        it.close();
      }
    } catch (Exception e) {
      LOGGER.debug("Error reading ffmpeg web filters: " + e.getLocalizedMessage());
    }
    return false;
View Full Code Here

    this.log = log;
  }

  @Override
  public void run() {
    LineIterator it = null;
    try {
      it = IOUtils.lineIterator(inputStream, "UTF-8");

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

        if (line.length() > 0) {
          addLine(line);
        }
View Full Code Here

      return null;
    }

    String version = null;

    LineIterator iterator = null;

    try {
      iterator = FileUtils.lineIterator(versionFile, null);

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

        if ("<key>CFBundleShortVersionString</key>".equals(line.trim())) {
          String versionLine = iterator.nextLine();

          version = versionLine.trim().replaceAll("</?string>", "");

          break;
        }
View Full Code Here

 
  private List<String> processContent(String content, StringBuilder excerptBuilder) {
    boolean excerptFound = false;
    List<String> contentLines = new ArrayList<String>();
    boolean lastLineIsBlank = true;
    LineIterator it = IOUtils.lineIterator(new StringReader(content));
    int preCount = 0;
    while(it.hasNext()){
      String line = it.next();
      boolean isBlank = StringUtils.isBlank(line);
      if(!isBlank){
        String lower = line.toLowerCase().trim();
        if(preCount == 0 && lastLineIsBlank && !lower.startsWith("<h") && !lower.startsWith("<!--more-->")){
          line = "<p>" + line;
View Full Code Here

    List<String> contentLines = new ArrayList<String>();
    InputStream stream = null;
    List<String> currentList = metaLines;
    try {
      stream = new FileInputStream(sourceEntry.getFile());
      LineIterator iterator = IOUtils.lineIterator(stream, "UTF-8");

      if(!iterator.hasNext()){
        throw new RuntimeException("File not content: " + sourceEntry.getFile());
      }
     
      String line = iterator.next();
      if(!isFrontMatterStartLine(line, sourceEntry)){
        log.debug("Maybe a static file: " + sourceEntry.getFile());
        throw new NoFrontMatterException(sourceEntry);
      }
     
      boolean hasFrontMatterEndLine = false;
      //process headers
      while(iterator.hasNext()){
        line = iterator.next();
        if(isFrontMatterEndLine(line)){
          hasFrontMatterEndLine = true;
          currentList = contentLines;
          continue;
        }
View Full Code Here

            long beginTime = System.currentTimeMillis();

            bis = new BufferedInputStream(is);
            String encoding = FileCharset.getCharset(bis);

            LineIterator iterator = IOUtils.lineIterator(bis, encoding);

            String separator = ",";
            int totalSize = 0; //总大小

            final List<ExcelData> dataList = Lists.newArrayList();

            if (iterator.hasNext()) {
                iterator.nextLine();//跳过第一行标题
            }

            while (iterator.hasNext()) {

                totalSize++;

                String line = iterator.nextLine();
                String[] dataArray = StringUtils.split(line, separator);

                ExcelData data = new ExcelData();
                data.setId(Long.valueOf(dataArray[0]));
                data.setContent(dataArray[1]);
View Full Code Here

    }

    private DeltaIndex readIndex(ZipInputStream patch) throws IOException {
        ZipEntry indexEntry = patch.getNextEntry();
        checkArgument(indexEntry.getName().startsWith(".index"), "Unexpected index file name: '{}', must start with '.index'");
        LineIterator iter = IOUtils.lineIterator(patch, "UTF-8");
        List<? extends IndexEntry> entries = ImmutableList.copyOf(Iterators.transform(iter, new IndexEntryMapper()));
        patch.closeEntry();
        ImmutableList<IndexEntry.Unchanged> unchanged = ImmutableList.copyOf(Iterables.filter(entries, IndexEntry.Unchanged.class));
        ImmutableList<IndexEntry.Created> created = ImmutableList.copyOf(Iterables.filter(entries, IndexEntry.Created.class));
        ImmutableList<IndexEntry.Updated> updated = ImmutableList.copyOf(Iterables.filter(entries, IndexEntry.Updated.class));
View Full Code Here

TOP

Related Classes of org.apache.commons.io.LineIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.