Package java.io

Examples of java.io.LineNumberReader


      this.parser.setDocumentLocator(locator);
      this.parser.startDocument();
      this.parser.startElement("http://chaperon.sourceforge.net/schema/text/1.0", "text", "text",
                               new AttributesImpl());

      LineNumberReader reader =
        new LineNumberReader(new InputStreamReader(new FileInputStream(inFile)));

      String line;
      String newline = null;
      String separator = System.getProperty("line.separator");

      while (true)
      {
        if (newline==null)
          line = reader.readLine();
        else
          line = newline;

        if (line==null)
          break;

        newline = reader.readLine();

        line = (newline!=null) ? (line+separator) : line;

        locator.setLineNumber(reader.getLineNumber());
        locator.setColumnNumber(1);
        this.parser.characters(line.toCharArray(), 0, line.length());

        if (newline==null)
          break;
      }

      reader.close();

      this.parser.endElement("http://chaperon.sourceforge.net/schema/text/1.0", "text", "text");
      this.parser.endDocument();
    }
    catch (SAXParseException se)
View Full Code Here


                ss = new ServerSocket(0);
                while (true) {
                    Socket socket = ss.accept();
                   
                    InputStream is = socket.getInputStream();
                    LineNumberReader lnr = new LineNumberReader(new InputStreamReader(is));
                   
                    // read first line
                    lnr.readLine();
                   
                    OutputStream out = socket.getOutputStream();
                    OutputStreamWriter w = new OutputStreamWriter(out);
                   
                    w.write(strbuf.toString());
View Full Code Here

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

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

        QAUtil.sleep(1000);
       
       
        BodyDataSource clientChannel = response.getBody();
        InputStream is = Channels.newInputStream(clientChannel);
        LineNumberReader lnr = new LineNumberReader(new InputStreamReader(is));
       
        StringBuilder sb = new StringBuilder();
        String line = null;
        do {
            line = lnr.readLine();
            if (line != null) {
                sb.append(line + "\r\n");
            }
        } while (line != null);


       
        InputStream is2 = new FileInputStream(file);
        LineNumberReader lnr2 = new LineNumberReader(new InputStreamReader(is2));
       
        StringBuilder sb2 = new StringBuilder();
        String line2 = null;
        do {
            line2 = lnr2.readLine();
            if (line2 != null) {
                sb2.append(line2 + "\r\n");
            }
        } while (line2 != null);
       
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();
    server.close();
View Full Code Here

        return null;
    }

    public static String line(final byte[] a, final int lineNr) {
        final InputStreamReader r = new InputStreamReader(new ByteArrayInputStream(a));
        final LineNumberReader lnr = new LineNumberReader(r);
        String theLine = null;
        while (lnr.getLineNumber() < lineNr) {
            try {
                theLine = lnr.readLine();
            } catch (final IOException e) {
                return null;
            }
            if (theLine == null) return null;
        }
View Full Code Here

        QAUtil.sleep(1000);
       
       
        BlockingBodyDataSource clientChannel = response.getBlockingBody();
        InputStream is = Channels.newInputStream(clientChannel);
        LineNumberReader lnr = new LineNumberReader(new InputStreamReader(is));
       
        StringBuilder sb = new StringBuilder();
        String line = null;
        do {
            line = lnr.readLine();
            if (line != null) {
                sb.append(line + "\r\n");
            }
        } while (line != null);


       
        InputStream is2 = new FileInputStream(file);
        LineNumberReader lnr2 = new LineNumberReader(new InputStreamReader(is2));
       
        StringBuilder sb2 = new StringBuilder();
        String line2 = null;
        do {
            line2 = lnr2.readLine();
            if (line2 != null) {
                sb2.append(line2 + "\r\n");
            }
        } while (line2 != null);
       
View Full Code Here

        QAUtil.sleep(1000);
       
       
        BlockingBodyDataSource clientChannel = response.getBlockingBody();
        InputStream is = Channels.newInputStream(clientChannel);
        LineNumberReader lnr = new LineNumberReader(new InputStreamReader(is));
       
        StringBuilder sb = new StringBuilder();
        String line = null;
        do {
            line = lnr.readLine();
            if (line != null) {
                sb.append(line + "\r\n");
            }
        } while (line != null);


       
        InputStream is2 = new FileInputStream(file);
        LineNumberReader lnr2 = new LineNumberReader(new InputStreamReader(is2));
       
        StringBuilder sb2 = new StringBuilder();
        String line2 = null;
        do {
            line2 = lnr2.readLine();
            if (line2 != null) {
                sb2.append(line2 + "\r\n");
            }
        } while (line2 != null);
       
View Full Code Here

        QAUtil.sleep(1000);
       
       
        BlockingBodyDataSource clientChannel = response.getBlockingBody();
        InputStream is = Channels.newInputStream(clientChannel);
        LineNumberReader lnr = new LineNumberReader(new InputStreamReader(is));
       
        StringBuilder sb = new StringBuilder();
        String line = null;
        do {
            line = lnr.readLine();
            if (line != null) {
                sb.append(line + "\r\n");
            }
        } while (line != null);


       
        InputStream is2 = new FileInputStream(file);
        LineNumberReader lnr2 = new LineNumberReader(new InputStreamReader(is2));
       
        StringBuilder sb2 = new StringBuilder();
        String line2 = null;
        do {
            line2 = lnr2.readLine();
            if (line2 != null) {
                sb2.append(line2 + "\r\n");
            }
        } while (line2 != null);
       
View Full Code Here

           
            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

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.