Example usage for java.io EOFException getMessage

List of usage examples for java.io EOFException getMessage

Introduction

In this page you can find the example usage for java.io EOFException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.sshtools.daemon.sftp.SftpSubsystemServer.java

private void onReadFile(SshFxpRead msg) {
    SubsystemMessage reply;//from  w  w w.j a  va2s . c  o  m

    try {
        reply = new SshFxpData(msg.getId(), nfs.readFile(msg.getHandle(), msg.getOffset(), msg.getLength()));
    } catch (EOFException eof) {
        reply = new SshFxpStatus(msg.getId(), new UnsignedInteger32(SshFxpStatus.STATUS_FX_EOF),
                eof.getMessage(), "");
    } catch (InvalidHandleException ihe) {
        reply = new SshFxpStatus(msg.getId(), new UnsignedInteger32(SshFxpStatus.STATUS_FX_FAILURE),
                ihe.getMessage(), "");
    } catch (IOException ioe2) {
        reply = new SshFxpStatus(msg.getId(), new UnsignedInteger32(SshFxpStatus.STATUS_FX_FAILURE),
                ioe2.getMessage(), "");
    }

    sendMessage(reply);
}

From source file:com.sshtools.daemon.sftp.SftpSubsystemServer.java

private void onReadDirectory(SshFxpReadDir msg) {
    SubsystemMessage reply;/*w  ww.j  av  a  2s.co m*/

    try {
        /*
           File[] files = nfs.readDirectory(msg.getHandle());
           SftpFile[] sftpfiles = new SftpFile[files.length];
           for (int i = 0; i < files.length; i++) {
           sftpfiles[i] = new SftpFile(files[i].getName(),
                nfs.getFileAttributes(files[i].getCanonicalPath()));
           }
         */
        SftpFile[] sftpfiles = nfs.readDirectory(msg.getHandle());

        reply = new SshFxpName(msg.getId(), sftpfiles);
    } catch (FileNotFoundException ioe) {
        reply = new SshFxpStatus(msg.getId(), new UnsignedInteger32(SshFxpStatus.STATUS_FX_NO_SUCH_FILE),
                ioe.getMessage(), "");
    } catch (InvalidHandleException ihe) {
        reply = new SshFxpStatus(msg.getId(), new UnsignedInteger32(SshFxpStatus.STATUS_FX_FAILURE),
                ihe.getMessage(), "");
    } catch (EOFException eof) {
        reply = new SshFxpStatus(msg.getId(), new UnsignedInteger32(SshFxpStatus.STATUS_FX_EOF),
                eof.getMessage(), "");
    } catch (IOException ioe2) {
        reply = new SshFxpStatus(msg.getId(), new UnsignedInteger32(SshFxpStatus.STATUS_FX_FAILURE),
                ioe2.getMessage(), "");
    }

    sendMessage(reply);
}

From source file:com.chicm.cmraft.log.DefaultRaftLog.java

private void loadPersistentData() {
    if (persistentDataLoaded) {
        return;//from  w ww  .  jav a  2 s .c o  m
    }
    try (FileInputStream fis = new FileInputStream(getStorageFilePath().toFile())) {
        long maxIndex = 0;
        while (true) {
            try {
                //LogEntry entry = (LogEntry)ois.readObject();
                RaftLogEntry.Builder builder = RaftLogEntry.newBuilder();
                if (!builder.mergeDelimitedFrom(fis)) {
                    break;
                }
                RaftLogEntry entry = builder.build();
                entries.put(entry.getIndex(), entry);
                if (entry.getIndex() > maxIndex) {
                    maxIndex = entry.getIndex();
                }

                setCommitIndex(maxIndex);
                setLastApplied(maxIndex);
                setFlushedIndex(maxIndex);

                replayKeyValueLogEntries(maxIndex, maxIndex);

            } catch (EOFException e) {
                break;
            }
        }
    } catch (FileNotFoundException e) {
        LOG.warn("no persistant data to load");
    } catch (IOException e) {
        LOG.error("ERROR loadPersistentData" + e.getMessage(), e);
        //Will not try to load again if exception occurs.
        //so still set loaded mark persistentDataLoaded
    }
    persistentDataLoaded = true;
}

From source file:com.amazon.sqs.javamessaging.message.SQSBytesMessage.java

/**
 * Reads a <code>boolean</code> from the bytes message stream.
 * /*w w w .j a  v a  2  s.  com*/
 * @return the <code>boolean</code> value
 * @throws JMSException
 *             If the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             If unexpected end of bytes stream has been reached.
 * @throws MessageNotReadableException
 *             If the message is in write-only mode.
 */
@Override
public boolean readBoolean() throws JMSException {
    checkCanRead();
    try {
        return dataIn.readBoolean();
    } catch (EOFException e) {
        throw new MessageEOFException(e.getMessage());
    } catch (IOException e) {
        throw convertExceptionToJMSException(e);
    }
}

From source file:com.amazon.sqs.javamessaging.message.SQSBytesMessage.java

/**
 * Reads a signed 8-bit value from the bytes message stream.
 * //from ww  w .  jav  a 2s .com
 * @return the next byte from the bytes message stream as a signed 8-bit
 *         byte
 * @throws JMSException
 *             If the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             If unexpected end of bytes stream has been reached.
 * @throws MessageNotReadableException
 *             If the message is in write-only mode.
 */
@Override
public byte readByte() throws JMSException {
    checkCanRead();
    try {
        return dataIn.readByte();
    } catch (EOFException e) {
        throw new MessageEOFException(e.getMessage());
    } catch (IOException e) {
        throw convertExceptionToJMSException(e);
    }
}

From source file:com.amazon.sqs.javamessaging.message.SQSBytesMessage.java

/**
 * Reads an unsigned 8-bit value from the bytes message stream.
 * /*from   w w  w .j a v a  2 s .c o m*/
 * @return the next byte from the bytes message stream, interpreted as an
 *         unsigned 8-bit number
 * @throws JMSException
 *             If the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             If unexpected end of bytes stream has been reached.
 * @throws MessageNotReadableException
 *             If the message is in write-only mode.
 */
@Override
public int readUnsignedByte() throws JMSException {
    checkCanRead();
    try {
        return dataIn.readUnsignedByte();
    } catch (EOFException e) {
        throw new MessageEOFException(e.getMessage());
    } catch (IOException e) {
        throw convertExceptionToJMSException(e);
    }
}

From source file:com.amazon.sqs.javamessaging.message.SQSBytesMessage.java

/**
 * Reads a signed 16-bit number from the bytes message stream.
 * /* w w w  .  ja v  a2  s.  c o m*/
 * @return the next two bytes from the bytes message stream, interpreted as
 *         a signed 16-bit number
 * @throws JMSException
 *             If the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             If unexpected end of bytes stream has been reached.
 * @throws MessageNotReadableException
 *             If the message is in write-only mode.
 */
@Override
public short readShort() throws JMSException {
    checkCanRead();
    try {
        return dataIn.readShort();
    } catch (EOFException e) {
        throw new MessageEOFException(e.getMessage());
    } catch (IOException e) {
        throw convertExceptionToJMSException(e);
    }
}

From source file:com.amazon.sqs.javamessaging.message.SQSBytesMessage.java

/**
 * Reads an unsigned 16-bit number from the bytes message stream.
 * //from ww  w  .  j  ava 2s.co  m
 * @return the next two bytes from the bytes message stream, interpreted as
 *         an unsigned 16-bit integer
 * @throws JMSException
 *             If the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             If unexpected end of bytes stream has been reached.
 * @throws MessageNotReadableException
 *             If the message is in write-only mode.
 */
@Override
public int readUnsignedShort() throws JMSException {
    checkCanRead();
    try {
        return dataIn.readUnsignedShort();
    } catch (EOFException e) {
        throw new MessageEOFException(e.getMessage());
    } catch (IOException e) {
        throw convertExceptionToJMSException(e);
    }
}

From source file:com.amazon.sqs.javamessaging.message.SQSBytesMessage.java

/**
 * Reads a Unicode character value from the bytes message stream. 
 * /*from  w  w w. j  ava2  s.  com*/
 * @return a Unicode character from the bytes message stream
 * @throws JMSException
 *             If the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             If unexpected end of bytes stream has been reached.
 * @throws MessageNotReadableException
 *             If the message is in write-only mode.
 */
@Override
public char readChar() throws JMSException {
    checkCanRead();
    try {
        return dataIn.readChar();
    } catch (EOFException e) {
        throw new MessageEOFException(e.getMessage());
    } catch (IOException e) {
        throw convertExceptionToJMSException(e);
    }
}

From source file:com.amazon.sqs.javamessaging.message.SQSBytesMessage.java

/**
 * Reads a 32-bit integer from the bytes message stream.
 * /*from w w w  .  j  a  va  2s  .c  om*/
 * @return the next four bytes from the bytes message stream, interpreted as an int
 * @throws JMSException
 *             If the JMS provider fails to read the message due to some
 *             internal error.
 * @throws MessageEOFException
 *             If unexpected end of bytes stream has been reached.
 * @throws MessageNotReadableException
 *             If the message is in write-only mode.
 */
@Override
public int readInt() throws JMSException {
    checkCanRead();
    try {
        return dataIn.readInt();
    } catch (EOFException e) {
        throw new MessageEOFException(e.getMessage());
    } catch (IOException e) {
        throw convertExceptionToJMSException(e);
    }
}