Package java.io

Examples of java.io.LineNumberReader


     
      Map<String, String> map = new HashMap<String, String>();
      mimeTypeMap = Collections.unmodifiableMap(map);
     
      InputStreamReader isr = null;
      LineNumberReader lnr = null;
      try {
        isr = new InputStreamReader(HttpUtils.class.getResourceAsStream("/org/xlightweb/mime.types"));
        if (isr != null) {
          lnr = new LineNumberReader(isr);
          String line = null;
          while (true) {
            line = lnr.readLine();
            if (line != null) {
              line = line.trim();
              if (!line.startsWith("#")) {
                StringTokenizer st = new StringTokenizer(line);
                if (st.hasMoreTokens()) {
                  String mimeType = st.nextToken();
                  while (st.hasMoreTokens()) {
                    String extension = st.nextToken();
                    map.put(extension, mimeType);
                     
                    if (LOG.isLoggable(Level.FINER)) {
                      LOG.finer("mapping " + extension + " -> " + mimeType + " added");
                    }
                  }
                } else {
                  if (LOG.isLoggable(Level.FINE)) {
                    LOG.fine("line " + line + "ignored");
                 
                }
              }
            } else {
              break;
            }
          }
   
          lnr.close();
        }
       
      } catch (Exception ioe) {
          // eat and log exception
        if (LOG.isLoggable(Level.FINE)) {
          LOG.fine("could not read mime.types. reason: " + ioe.toString());
        }       
       
      } finally {
        try {
          if (lnr != null) {
            lnr.close();
          }
           
          if (isr != null) {
            isr.close();
          }
View Full Code Here


   
    implementationVersion = "<unknown>";
    implementationDate = "<unknown>";
     
    InputStreamReader isr = null;
    LineNumberReader lnr = null;
   
    try {
      isr = new InputStreamReader(HttpUtils.class.getResourceAsStream("/org/xlightweb/version.txt"));
      if (isr != null) {
        lnr = new LineNumberReader(isr);
        String line = null;
   
        do {
          line = lnr.readLine();
          if (line != null) {
            if (line.startsWith("Implementation-Version=")) {
              implementationVersion = line.substring("Implementation-Version=".length(), line.length()).trim();
             
            } else if (line.startsWith("Implementation-Date=")) {
              implementationDate = line.substring("Implementation-Date=".length(), line.length()).trim();
             
            } else if (line.startsWith("Dependency.xSocket.Implementation-Version=")) {
                            xSocketImplementationVersion = line.substring("Dependency.xSocket.Implementation-Version=".length(), line.length()).trim();
                        }
          }
        } while (line != null);
       
        lnr.close();
      }
    } catch (Exception ioe) {
       
            implementationDate = "<unknown>";
            implementationVersion  = "<unknown>";
            xSocketImplementationVersion  = "<unknown>";
                   
      if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("could not read version file. reason: " + ioe.toString());
      }       
     
    } finally {
      try {
        if (lnr != null) {
          lnr.close();
        }
         
        if (isr != null) {
          isr.close();
        }
View Full Code Here

    FileChannel fc = raf.getChannel();
    response.getBlockingBody().transferTo(fc);
    fc.close();
    raf.close();

    LineNumberReader lnr = new LineNumberReader(new FileReader(file));
    String line = lnr.readLine();
   
    Assert.assertEquals("method= GET", line);
   
    file.delete();
    httpClient.close();
View Full Code Here

                        .multiplyBy(m.raiseTo(-1).multiplyBy(1e9)).multiplyBy(
                                s.raiseTo(-1).multiplyBy(1e9).raiseTo(-1))
                        .multiplyBy(m).divideBy(s));
                myAssert(parser, "m/km", m.divideBy(m.multiplyBy(1e3)));

            LineNumberReader    lineInput = new LineNumberReader(
                                    new InputStreamReader(System.in));

            for (;;)
            {
                System.out.print("Enter a unit specification or ^D to quit: ");

                String  spec = lineInput.readLine();
                if (spec == null)
                    break;

                try
                {
View Full Code Here

    StringBuffer oCty = new StringBuffer(65000);
    String sLine, sCountryCode, sPlaceCode, sPlaceName, sPort, sRail, sRoad, sAirport, sPostal, sStatus, sIata, sLat, sLong;
    FileWriter oLC = new FileWriter(sOutFile);
    FileWriter oCC = new FileWriter(sCountries);
    FileReader oFR = new FileReader(sInFile);
    LineNumberReader oLR = new LineNumberReader(oFR);
    while ( null!= (sLine = oLR.readLine()) ) {
      sCountryCode = sLine.substring(3,5).toLowerCase();
      sPlaceCode = sLine.substring(6,9).toLowerCase();
      sPlaceName = sLine.substring(10,46).trim().replace((char)39,'ยด');
      if (sPlaceName.charAt(0)!='.') {
        sPort = (sLine.charAt(86)=='1' ? "1" : "0");
        sRail = (sLine.charAt(87)=='2' ? "1" : "0");
        sRoad = (sLine.charAt(88)=='3' ? "1" : "0");
        sAirport = (sLine.charAt(89)=='4' ? "1" : "0");
        sPostal = (sLine.charAt(90)=='5' ? "1" : "0");
        sStatus = sLine.substring(95,97).trim();
        sIata = sLine.substring(103,106).trim();
        if (sIata.length()>0)
          sIata = "'"+sIata+"'";
        else
          sIata = "null";
        sLat = sLine.substring(108,113).trim();
        if (sLat.length()>0)
          sLat = "'"+sLat+"'";
        else
          sLat = "null";
        sLong = sLine.substring(114,120).trim();
        if (sLong.length()>0)
          sLong = "'"+sLong+"'";
        else
          sLong = "null";
        oLC.write("INSERT INTO k_lu_unlocode (id_country,id_place,nm_place,bo_active,bo_port,bo_rail,bo_road,bo_airport,bo_postal,id_status,id_iata,coord_lat,coord_long) VALUES('"+sCountryCode+"','"+sPlaceCode+"','"+sPlaceName+"',1,"+sPort+","+sRail+","+sRoad+","+sAirport+","+sPostal+",'"+sStatus+"',"+sIata+","+sLat+","+sLong+");\n");
      } else {
        oCC.write(sCountryCode+" "+sPlaceName.substring(1)+"\n");
      }
    } // wend
    oLR.close();
    oFR.close();
    oCC.close();
    oLC.close();
  }
View Full Code Here

   logger.info("Start creating task file for crawl");
  
   //*-- before creating a task file, check for a restart
   if (crawlConfig.getStartPosition() != -1)
   { ctRef.fileReadTime -= new Date().getTime();
     int numFiles = 0; LineNumberReader fileno = null;
     try
     { fileno = new LineNumberReader(new FileReader(taskFile));
       while ((fileno.readLine()) != null) numFiles++;
     }
     catch (IOException ie) { logger.error("IO Error in task file " + taskFile + " " + ie.getMessage()); }
     finally { try { if (fileno != null) fileno.close(); }
               catch (IOException ie) { logger.error("Ignore error"); } }
     setNumFiles(numFiles);
     ctRef.fileReadTime += new Date().getTime();
     return;
   }
View Full Code Here

            : new DefaultEntityImporter(clazz);
        importer.setReader(new ExcelItemReader(is, 1));
        put("importer", importer);
        return importer;
      } else {
        LineNumberReader reader = new LineNumberReader(new InputStreamReader(is));
        if (null == reader.readLine()) return null;
        reader.reset();
        EntityImporter importer = (clazz == null) ? new DefaultEntityImporter()
            : new DefaultEntityImporter(clazz);
        importer.setReader(new CsvItemReader(reader));
        return importer;
      }
View Full Code Here

    public void run(){
        while(true){
            Socket socket = null;
            try{
                socket = _socket.accept();
                LineNumberReader lin =
                        new LineNumberReader(new InputStreamReader(socket.getInputStream()));
                String key = lin.readLine();
                if(!_key.equals(key))
                    continue;

                String cmd = lin.readLine();
                if(STOP_CMD.equals(cmd)){
        AlertEngine.getInstance().stop();
        logger.info("Shutting down the server.");

                    try{
View Full Code Here

            fail("Error comparing files " + refFile + " and " + outFile + "\n" + sw.toString());
        }
    }

    static public void compare(Reader reference, Reader output) throws IOException {
        LineNumberReader ref = new LineNumberReader(reference);
        LineNumberReader out = new LineNumberReader(output);
        String refLine = "", outLine = "";
        while (refLine != null || outLine != null) {
            if (refLine == null) {
                fail("Output text is longer than reference text");
            }
            if (outLine == null) {
                fail("Output text is shorter than reference text");
            }
            refLine = ref.readLine();
            outLine = out.readLine();
            if (refLine != null && outLine != null & !refLine.equals(outLine)) {
                fail("Difference found on line " + ref.getLineNumber() +
                                            ".\nReference text is: " + refLine +
                                            "\nOutput text is: " + outLine);
            }
View Full Code Here

            log.debug(sourceCode);
          }

          if (sourceCode != null) {
            boolean containsGenerationTags = false;
            LineNumberReader sourceFileReader = new LineNumberReader(new StringReader(sourceCode));
            StringBuffer sourceCodeBuffer = new StringBuffer();
            log.debug("Line number " + sourceFileReader.getLineNumber());
            String line = null;
            boolean startGeneration = false;
            while ((line = sourceFileReader.readLine()) != null) {
              if (line.contains("@StartGeneration")) {
                sourceCodeBuffer.append(line);
                sourceCodeBuffer.append("\n");
                startGeneration = true;
                containsGenerationTags = true;
View Full Code Here

TOP

Related Classes of java.io.LineNumberReader

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.