Package java.io

Examples of java.io.LineNumberReader


          }


          if (sourceCode != null) {
            boolean containsGenerationTags = false;
            LineNumberReader sourceFileReader = new LineNumberReader(new StringReader(sourceCode));
            StringBuffer sourceCodeBuffer = new StringBuffer();           
            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


    write(returnpath, recipients, msg, out);
    out.close();
  }

  public void stream(Reader reader) throws Exception {
    LineNumberReader lineNumberReader = new LineNumberReader(reader);
    OutputStream out = null;
    for (String line; (line = lineNumberReader.readLine()) != null;) {
      if (line.startsWith("##To:")) {
        if (out != null) {
          out.close();
        }
        out = newOutputStream();
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

                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

                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

                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

    private void putASCII(InputStream srcStream, String remoteFile,
                          boolean append)
        throws IOException, FTPException {

        // need to read line by line ...
        LineNumberReader in
            = new LineNumberReader(new InputStreamReader(srcStream));

        initPut(remoteFile, append);

        // get an character output stream to write to ... AFTER we
        // have the ok to go ahead AND AFTER we've successfully opened a
        // stream for the local file
        BufferedWriter out =
            new BufferedWriter(
                new OutputStreamWriter(data.getOutputStream()));

        // write line by line, writing \r\n as required by RFC959 after
        // each line
        String line = null;
        while ((line = in.readLine()) != null) {
            out.write(line, 0, line.length());
            out.write(FTPControlSocket.EOL, 0, FTPControlSocket.EOL.length());
        }
        in.close();
        out.flush();
        out.close();

        // and close the data socket
        try {
View Full Code Here

                new FileWriter(localPath));

        // get an character input stream to read data from ... AFTER we
        // have the ok to go ahead AND AFTER we've successfully opened a
        // stream for the local file
        LineNumberReader in =
            new LineNumberReader(
                new InputStreamReader(data.getInputStream()));

        // B. McKeown:
        // If we are in active mode we have to set the timeout of the passive
        // socket. We can achieve this by calling setTimeout() again.
        // If we are in passive mode then we are merely setting the value twice
        // which does no harm anyway. Doing this simplifies any logic changes.
        data.setTimeout(timeout);

        // read/write a line at a time
        IOException storedEx = null;
        String line = null;
        try {
            while ((line = in.readLine()) != null) {
                out.write(line, 0, line.length());
                out.newLine();
            }
        }
        catch (IOException ex) {
            storedEx = ex;
            localFile.delete();
        }
        finally {
            out.close();
        }

        try {
            in.close();
            data.close();
        }
        catch (IOException ignore) {}

        // if we failed to write the file, rethrow the exception
View Full Code Here

            new BufferedWriter(
                new OutputStreamWriter(destStream));

        // get an character input stream to read data from ... AFTER we
        // have the ok to go ahead
        LineNumberReader in =
            new LineNumberReader(
                new InputStreamReader(data.getInputStream()));

        // B. McKeown:
        // If we are in active mode we have to set the timeout of the passive
        // socket. We can achieve this by calling setTimeout() again.
        // If we are in passive mode then we are merely setting the value twice
        // which does no harm anyway. Doing this simplifies any logic changes.
        data.setTimeout(timeout);

        // read/write a line at a time
        IOException storedEx = null;
        String line = null;
        try {
            while ((line = in.readLine()) != null) {
                out.write(line, 0, line.length());
                out.newLine();
            }
        }
        catch (IOException ex) {
            storedEx = ex;
        }
        finally {
            out.close();
        }

        try {
            in.close();
            data.close();
        }
        catch (IOException ignore) {}

        // if we failed to write the file, rethrow the exception
View Full Code Here

        // a normal reply ... extract the file list
        String replyCode = lastValidReply.getReplyCode();
        if (!replyCode.equals("450") && !replyCode.equals("550")) {
            // get an character input stream to read data from .
            LineNumberReader in =
                new LineNumberReader(
                     new InputStreamReader(data.getInputStream()));

            // read a line at a time
            Vector lines = new Vector();   
            String line = null;
            while ((line = in.readLine()) != null) {
                lines.add(line);
            }       
            try {
                in.close();
                data.close();
            }
            catch (IOException ignore) {}
               
            // check the control response
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.