Examples of LineIterator


Examples of org.apache.commons.io.LineIterator

     * @param in
     * @param validate if mappings should be validated before adding
     * @throws IOException
     */
    private void readPrefixMappings(InputStream in,boolean validate) 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

Examples of org.apache.commons.io.LineIterator

     * 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

Examples of org.apache.commons.io.LineIterator

            if(reader != null){
                closeQuietly(reader);
            }
            final Pattern p = Pattern.compile(".*" + expr + ".*");
            reader = new InputStreamReader(blob.getStream(), charset);
            final LineIterator it = new LineIterator(reader);
            while (it.hasNext()) {
                final String line = it.nextLine();
                if (p.matcher(line).matches()) {
                    continue nextPattern;
                }
            }
            fail(this + ": no match for regexp '" + expr + "', content=\n" +
View Full Code Here

Examples of org.apache.commons.io.LineIterator

        return dfp.getInputStream(null, resource, null);
    }

    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

Examples of org.apache.commons.io.LineIterator

        return in;
    }

    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

Examples of org.apache.commons.io.LineIterator

        //UTF-8, but some configurations might want to use URLs as keys!
        Map<String,Object> configMap = new HashMap<String,Object>();
        try {
            InputStream in = openConfig(configFile);
            if(in != null){
                LineIterator lines = IOUtils.lineIterator(in, "UTF-8");
                while(lines.hasNext()){
                    String line = (String)lines.next();
                    if(!line.isEmpty()){
                        int indexOfEquals = line.indexOf('=');
                        String key = indexOfEquals > 0 ?
                                line.substring(0,indexOfEquals).trim():
                                    line.trim();
View Full Code Here

Examples of org.apache.commons.io.LineIterator

      IHasTimeZone tz = (IHasTimeZone) log.getAdapter(IHasTimeZone.class);
      if (tz != null) {
        // Apply the timezone
        getPatternTranslator().applyTimeZone(tz.getTimeZone(), rules);
      }
      LineIterator iter = IOUtils.lineIterator(input, enc.getEncoding());
      int minLinesPerEntry = getPatternTranslator().getMinLinesPerEntry();
      int lineNo = 0;
      int moreLinesToCome = 0;
      try {
        String line = null;
        while (iter.hasNext()) {
          lineNo++;
         
          if (minLinesPerEntry == 1) {
            // Simple case
            line = iter.nextLine();
          } else {
            String s = iter.nextLine();
            if (moreLinesToCome == 0) {
              Matcher m = getInternalPatternFirstLine().matcher(s);
              if (m.find()) {
                // First line
                line = s;
                moreLinesToCome = minLinesPerEntry - 1;
                continue;
              } else {
                // Some crazy stuff
                line = s;
              }
            } else if (iter.hasNext() && (moreLinesToCome > 1)) {
              // Some middle line
              line += IOUtils.LINE_SEPARATOR + s;
              moreLinesToCome--;
              continue;
            } else {
              // Last line
              line += IOUtils.LINE_SEPARATOR + s;
              if (!iter.hasNext()) {
                line += IOUtils.LINE_SEPARATOR;
              }
              moreLinesToCome = 0;
            }
          }
View Full Code Here

Examples of org.apache.commons.io.LineIterator

      LogEntry currentEntry = null;
      IHasEncoding enc = (IHasEncoding) log.getAdapter(IHasEncoding.class);
      IHasLocale loc = (IHasLocale) log.getAdapter(IHasLocale.class);
      // WebSphere Dialect doesn't need to care about the timezone, because it is encoded in the log messages
      DateFormat df = getDateFormat(loc.getLocale());
      LineIterator iter = IOUtils.lineIterator(input, enc.getEncoding());
      int lineNo = 0;
      try {
        while (iter.hasNext()) {
          // Error handling
          lineNo++;
          List<IStatus> statuses = null;
          boolean fatal = false; // determines whether to interrupt parsing
         
          String line = iter.nextLine();
          Matcher m = getInternalPattern().matcher(line);
          if (m.find()) {
            // The next line matches, so flush the previous entry and continue
            if (currentEntry != null) {
              collector.collect(currentEntry);
View Full Code Here

Examples of org.apache.commons.io.LineIterator

   *
   * @param work
   */
  protected void extractFileMapResult(InitialMapWork work) {
    LinkedList<Future<Map<String, Integer>>> futureResults = new LinkedList<Future<Map<String, Integer>>>();
    LineIterator lineIterator = null;
    try {
      File fileToCount = work.getFileToCount();
      lineIterator = FileUtils.lineIterator(fileToCount);

      while (lineIterator.hasNext()) {
        // All work including special character handling done at worker
        // level
        String line = lineIterator.nextLine();
        // key is just the file name - initial mapping is easy
        // hard part comes with partitioning and reduction
        // we assume that we have unique file names in the dir
        MapWork newWork = new MapWork(fileToCount.getName(), line);

        Future<Map<String, Integer>> future = this.workRouter
            .sendRequestReplyFuture(newWork, 30000, getContext());
        future.await();
        futureResults.add(future);
      }

      // FinalMapResult result = new FinalMapResult(
      // (LinkedList<Future<Map<String, Integer>>>) futureResults);
      getContext().channel().sendOneWay(futureResults);
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      if (lineIterator != null) {
        lineIterator.close();
      }
    }
  }
View Full Code Here

Examples of org.apache.commons.io.LineIterator

          if ((!item.isFormField()) && (item.getFieldName().equals("file1"))) {
           
            String fileName = item.getName();
            if (fileName.length()>0){
              try {
                LineIterator it =  IOUtils.lineIterator(in, "UTF-8");
                while (it.hasNext()) {
                  String line = it.nextLine();
 
                  PersistenceManager pm = PMF.get().getPersistenceManager();
                  try  {
                    pm.makePersistent(processMessage(line));
                    messageCount ++;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.