Package java.io

Examples of java.io.EOFException


   *  Or if readBytes bytes are read, client read is finished => invoke readCallback (onSuccess)
   *  Of if end-of-stream is reached => invoke readCallback (onFailure)
   */
  private void checkReadState() {
    if (reachedEOF) {
      invokeReadFailureCallback(new EOFException("Reached end-of-stream"));
      return;
    }
    int index = readBuffer.indexOf(readDelimiter);
    if (index != -1 && !readDelimiter.isEmpty()) {
      String result = readBuffer.substring(0, index /*+ readDelimiter.length()*/);
 
View Full Code Here


       
        byte[] buf = new byte[length];
        int n = 0;
        do {
          int count = read(buf, n, length - n);
          if (count < 0) throw new EOFException();
          n += count;
        } while (n < length);
        ois = new ObjectInputStream(new GZIPInputStream(new ByteArrayInputStream(buf)));
      } else {
        ois = new ObjectInputStream(this);
View Full Code Here

      }
      FileInputStream fis = new FileInputStream(file);
      byte[] buf = new byte[(int) file.length()];
      for (int nb=0; nb<buf.length; ) {
        int ret = fis.read(buf, nb, buf.length-nb);
        if (ret == -1) throw new EOFException();
        nb += ret;
      }
      fis.close();

      nbloaded += 1;   
View Full Code Here

                        case GossipRouter.CLOSE:
                            close();
                            break;
                           
                        case -1: // EOF
                            notifyAbnormalConnectionTear(this, new EOFException("Connection broken"));
                            break;
                    }
                    if(log.isTraceEnabled())
                        log.trace(this + " processed  " + request);
                }
View Full Code Here


    public static Frame readFrame(DataInputStream in) throws IOException {
        String verb=Util.readLine(in);
        if(verb == null)
            throw new EOFException("reading verb");
        if(verb.length() == 0)
            return null;
        verb=verb.trim();
       
        Map<String,String> headers=new HashMap<String,String>();
        byte[] body=null;

        for(;;) {
            String header=Util.readLine(in);
            if(header == null)
                throw new EOFException("reading header");
            if(header.length() == 0)
                break;
            int index=header.indexOf(":");
            if(index != -1)
                headers.put(header.substring(0, index).trim(), header.substring(index+1).trim());
View Full Code Here

  final void readFully(InputStream is, byte[] iobuf) throws IOException {
    int n = 0;
    do {
      int count = is.read(iobuf, n, iobuf.length - n);
      if (count < 0) throw new EOFException();
      n += count;
    } while (n < iobuf.length);
  }
View Full Code Here

      do {
        if (getLogger().isLoggable(BasicLevel.DEBUG))
          getLogger().log(BasicLevel.DEBUG, "read(" + count + ')');
       
        int nb = in.read(buf, count, buf.length - count);
        if (nb < 0) throw new EOFException();
        count += nb;
      } while (count < length);
    }
   
    if (getLogger().isLoggable(BasicLevel.DEBUG))
View Full Code Here

      }
      FileInputStream fis = new FileInputStream(file);
      byte[] buf = new byte[(int) file.length()];
      for (int nb=0; nb<buf.length; ) {
        int ret = fis.read(buf, nb, buf.length-nb);
        if (ret == -1) throw new EOFException();
        nb += ret;
      }
      fis.close();

      return buf;
View Full Code Here

    public static void writeFully(final WritableByteChannel channel, final ByteBuffer buf)
            throws IOException {
        do {
            int written = channel.write(buf);
            if(written < 0) {
                throw new EOFException();
            }
        } while(buf.hasRemaining());
    }
View Full Code Here

        if (! (readerWriter instanceof BufferedReader)) {
            setError(new IllegalStateException("File not opened for reading"));
            return null;
        }
        if (atEOF) {
            setError(new EOFException());
            return null;
        }
        if (lastLine!=null) {
            String line = lastLine;
            lastLine = null;
            return line;
        }
        BufferedReader reader = (BufferedReader) readerWriter;
        // Here lastLine is null, return a new line
        try {
          String line = reader.readLine();
          if (line == null) {
              atEOF = true;
              setError(new EOFException());
          }
          return line;
        } catch (IOException e) {
          setError(e);
          return null;
View Full Code Here

TOP

Related Classes of java.io.EOFException

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.