Java Code Examples for java.io.EOFException

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project candlepin, under directory /src/test/java/org/candlepin/exceptions/mappers/.

Source file: ApplicationExceptionMapperTest.java

  18 
vote

@Test public void withCause(){
  EOFException eofe=new EOFException("screwed");
  ApplicationException ae=new ApplicationException("oops",eofe);
  ApplicationExceptionMapper aem=injector.getInstance(ApplicationExceptionMapper.class);
  Response r=aem.toResponse(ae);
  assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),r.getStatus());
  verifyMessage(r,rtmsg("oops"));
}
 

Example 2

From project adbcj, under directory /api/src/main/java/org/adbcj/support/.

Source file: DecoderInputStream.java

  17 
vote

public byte readByte() throws IOException {
  int ch=read();
  if (ch < 0) {
    throw new EOFException();
  }
  return (byte)(ch);
}
 

Example 3

From project AlbiteREADER, under directory /src/gnu/zip/.

Source file: ZipFile.java

  17 
vote

int readLeShort() throws IOException {
  int result;
  if (pos + 1 < buffer.length) {
    result=((buffer[pos + 0] & 0xff) | (buffer[pos + 1] & 0xff) << 8);
    pos+=2;
  }
 else {
    int b0=read();
    int b1=read();
    if (b1 == -1)     throw new EOFException();
    result=(b0 & 0xff) | (b1 & 0xff) << 8;
  }
  return result;
}
 

Example 4

From project Amoeba-for-Aladdin, under directory /src/java/com/meidusa/amoeba/mysql/net/packet/.

Source file: BlockedPacketIO.java

  17 
vote

public static final int readFully(InputStream in,byte[] b,int off,int len) throws IOException {
  if (len < 0) {
    throw new IndexOutOfBoundsException();
  }
  int n=0;
  while (n < len) {
    int count=in.read(b,off + n,len - n);
    if (count < 0) {
      throw new EOFException(Messages.getString("MysqlIO.EOF",new Object[]{new Integer(len),new Integer(n)}));
    }
    n+=count;
  }
  return n;
}
 

Example 5

From project android-aac-enc, under directory /src/com/coremedia/iso/.

Source file: ChannelHelper.java

  17 
vote

public static int readFully(final ReadableByteChannel channel,final ByteBuffer buf,final int length) throws IOException {
  int n, count=0;
  while (-1 != (n=channel.read(buf))) {
    count+=n;
    if (count == length) {
      break;
    }
  }
  if (n == -1) {
    throw new EOFException("End of file. No more boxes.");
  }
  return count;
}
 

Example 6

From project android_5, under directory /src/aarddict/.

Source file: RandomAccessFile.java

  17 
vote

public final long readUnsignedInt() throws IOException {
  int ch1=this.read();
  int ch2=this.read();
  int ch3=this.read();
  int ch4=this.read();
  if ((ch1 | ch2 | ch3| ch4) < 0)   throw new EOFException();
  return ((long)(ch1 << 24) + (ch2 << 16) + (ch3 << 8)+ (ch4 << 0)) & 0xFFFFFFFFL;
}
 

Example 7

From project android_external_guava, under directory /src/com/google/common/io/.

Source file: ByteStreams.java

  17 
vote

/** 
 * Discards  {@code n} bytes of data from the input stream. This methodwill block until the full amount has been skipped. Does not close the stream.
 * @param in the input stream to read from
 * @param n the number of bytes to skip
 * @throws EOFException if this stream reaches the end before skipping allthe bytes
 * @throws IOException if an I/O error occurs, or the stream does notsupport skipping
 */
public static void skipFully(InputStream in,long n) throws IOException {
  while (n > 0) {
    long amt=in.skip(n);
    if (amt == 0) {
      if (in.read() == -1) {
        throw new EOFException();
      }
      n--;
    }
 else {
      n-=amt;
    }
  }
}
 

Example 8

From project archive-commons, under directory /archive-commons/src/main/java/org/archive/util/.

Source file: ByteOp.java

  17 
vote

public static int readShort(InputStream is) throws IOException {
  int b1=is.read();
  if (b1 == -1) {
    throw new EOFException("No bytes expected short(2)");
  }
  int b2=is.read();
  if (b2 == -1) {
    throw new EOFException("One byte expected short(2)");
  }
  return bytesToShort(b1,b2);
}
 

Example 9

From project ARCInputFormat, under directory /src/org/commoncrawl/util/shared/.

Source file: ArcFileReader.java

  17 
vote

private static int readUByte(InputStream in) throws IOException {
  int b=in.read();
  if (b == -1) {
    throw new EOFException();
  }
  if (b < -1 || b > 255) {
    throw new IOException("read() returned value out of range -1..255: " + b);
  }
  return b;
}
 

Example 10

From project ardverk-commons, under directory /src/main/java/org/ardverk/io/.

Source file: ByteUtils.java

  17 
vote

/** 
 * @see DataInput#readFully(byte[])
 */
public static byte[] readFully(InputStream in,byte[] dst,int offset,int length) throws IOException {
  int total=0;
  while (total < length) {
    int r=in.read(dst,offset + total,length - total);
    if (r == -1) {
      throw new EOFException();
    }
    total+=r;
  }
  return dst;
}
 

Example 11

From project avro, under directory /lang/java/avro/src/main/java/org/apache/avro/io/.

Source file: BinaryDecoder.java

  17 
vote

@Override public boolean readBoolean() throws IOException {
  if (limit == pos) {
    limit=source.tryReadRaw(buf,0,buf.length);
    pos=0;
    if (limit == 0) {
      throw new EOFException();
    }
  }
  int n=buf[pos++] & 0xff;
  return n == 1;
}
 

Example 12

From project b1-pack, under directory /standard/src/main/java/org/b1/pack/standard/reader/.

Source file: ChunkedInputStream.java

  17 
vote

@Override public int read() throws IOException {
  if (isEnd()) {
    return -1;
  }
  int result=stream.read();
  if (result == -1) {
    throw new EOFException();
  }
  count--;
  return result;
}
 

Example 13

From project bson4jackson, under directory /src/main/java/de/undercouch/bson4jackson/io/.

Source file: LittleEndianInputStream.java

  17 
vote

@Override public void readFully(byte[] b,int off,int len) throws IOException {
  while (len > 0) {
    int r=read(b,off,len);
    if (r < 0) {
      throw new EOFException();
    }
    len-=r;
    off+=r;
  }
}
 

Example 14

From project btmidi, under directory /BluetoothMidiPlayer/src/com/noisepages/nettoyeur/midi/file/.

Source file: StandardMidiFileReader.java

  17 
vote

private int readIntFromStream() throws IOException {
  try {
    return stream.readInt();
  }
 catch (  EOFException eof) {
    throw new EOFException("invalid MIDI file");
  }
}
 

Example 15

From project ciel-java, under directory /examples/skyhout/src/java/skywriting/examples/skyhout/common/.

Source file: FakeSeekable.java

  17 
vote

@Override public void readFully(long position,byte[] buffer,int offset,int length) throws IOException {
  int bytesRead=this.read(position,buffer,offset,length);
  if (bytesRead < length) {
    throw new EOFException("Attempted to readFully past the end of the file.");
  }
}
 

Example 16

From project cometd, under directory /cometd-java/cometd-websocket-jetty/src/main/java/org/cometd/websocket/client/.

Source file: WebSocketTransport.java

  17 
vote

public void onClose(int closeCode,String message){
  Connection connection=_connection;
  _connection=null;
  debug("Closed websocket connection with code {} {}: {} ",closeCode,message,connection);
  failMessages(new EOFException("Connection closed " + closeCode + " "+ message));
}
 

Example 17

From project commons-compress, under directory /src/main/java/org/apache/commons/compress/archivers/dump/.

Source file: DumpArchiveInputStream.java

  17 
vote

/** 
 * Read CLRI (deleted inode) segment.
 */
private void readCLRI() throws IOException {
  byte[] readBuf=raw.readRecord();
  if (!DumpArchiveUtil.verify(readBuf)) {
    throw new InvalidFormatException();
  }
  active=DumpArchiveEntry.parse(readBuf);
  if (DumpArchiveConstants.SEGMENT_TYPE.CLRI != active.getHeaderType()) {
    throw new InvalidFormatException();
  }
  if (raw.skip(DumpArchiveConstants.TP_SIZE * active.getHeaderCount()) == -1) {
    throw new EOFException();
  }
  readIdx=active.getHeaderCount();
}
 

Example 18

From project commons-io, under directory /src/main/java/org/apache/commons/io/.

Source file: EndianUtils.java

  17 
vote

/** 
 * Reads the next byte from the input stream.
 * @param input  the stream
 * @return the byte
 * @throws IOException if the end of file is reached
 */
private static int read(InputStream input) throws IOException {
  int value=input.read();
  if (-1 == value) {
    throw new EOFException("Unexpected EOF reached");
  }
  return value;
}
 

Example 19

From project crammer, under directory /src/main/java/uk/ac/ebi/ena/sra/cram/io/.

Source file: DefaultBitInputStream.java

  17 
vote

public final boolean readBit() throws IOException {
  if (--nofBufferedBits >= 0)   return ((byteBuffer >>> nofBufferedBits) & 1) == 1;
  nofBufferedBits=7;
  byteBuffer=in.read();
  if (byteBuffer == -1) {
    endOfStream=true;
    if (throwEOF)     throw new EOFException("End of stream.");
  }
  return ((byteBuffer >>> 7) & 1) == 1;
}
 

Example 20

From project curator, under directory /curator-recipes/src/main/java/com/netflix/curator/framework/recipes/leader/.

Source file: LeaderLatch.java

  17 
vote

/** 
 * <p>Causes the current thread to wait until this instance acquires leadership unless the thread is  {@linkplain Thread#interrupt interrupted} or {@linkplain #close() closed}.</p> <p>If this instance already is the leader then this method returns immediately.</p> <p>Otherwise the current thread becomes disabled for thread scheduling purposes and lies dormant until one of three things happen: <ul> <li>This instance becomes the leader</li> <li>Some other thread  {@linkplain Thread#interrupt interrupts}the current thread</li> <li>The instance is  {@linkplain #close() closed}</li> </ul></p> <p>If the current thread: <ul> <li>has its interrupted status set on entry to this method; or <li>is  {@linkplain Thread#interrupt interrupted} while waiting,</ul> then  {@link InterruptedException} is thrown and the current thread'sinterrupted status is cleared.</p>
 * @throws InterruptedException if the current thread is interruptedwhile waiting
 * @throws EOFException if the instance is {@linkplain #close() closed}while waiting
 */
public void await() throws InterruptedException, EOFException {
synchronized (this) {
    while ((state.get() == State.STARTED) && !hasLeadership.get()) {
      wait();
    }
  }
  if (state.get() != State.STARTED) {
    throw new EOFException();
  }
}
 

Example 21

From project daap, under directory /src/main/java/org/ardverk/daap/.

Source file: DaapInputStream.java

  17 
vote

public int read() throws IOException {
  int b=super.read();
  if (b < 0) {
    throw new EOFException();
  }
  return b;
}
 

Example 22

From project dcm4che, under directory /dcm4che-core/src/main/java/org/dcm4che/io/.

Source file: DicomInputStream.java

  17 
vote

public byte[] readValue() throws IOException {
  if (length < 0)   throw new EOFException();
  int allocLen=Math.min(length,ALLOC_INC);
  byte[] value=new byte[allocLen];
  readFully(value,0,allocLen);
  while (allocLen < length) {
    int newLength=Math.min(length,allocLen + ALLOC_INC);
    value=Arrays.copyOf(value,newLength);
    readFully(value,allocLen,newLength - allocLen);
    allocLen=newLength;
  }
  return value;
}
 

Example 23

From project derric, under directory /src/org/derric_lang/validator/.

Source file: OrderedInputStream.java

  17 
vote

@Override public int read() throws IOException {
  int r=super.read();
  if (r == -1)   throw new EOFException();
  byte[] b={(byte)r};
  _bitOrder.apply(b);
  return b[0] & 0xFF;
}
 

Example 24

From project droid-comic-viewer, under directory /src/com/github/junrar/io/.

Source file: ReadOnlyAccessByteArray.java

  17 
vote

public void setPosition(long pos) throws IOException {
  if (pos < file.length && pos >= 0) {
    this.positionInFile=(int)pos;
  }
 else {
    throw new EOFException();
  }
}
 

Example 25

From project Eclipse, under directory /com.mobilesorcery.sdk.core/src/com/mobilesorcery/sdk/core/.

Source file: Util.java

  17 
vote

public static short readShort(InputStream input) throws IOException {
  byte[] shortBuf=new byte[2];
  int totalRead=0;
  for (int read=input.read(shortBuf,totalRead,2 - totalRead); read != 2 && totalRead < 2; read=input.read(shortBuf,totalRead,2 - totalRead)) {
    if (read < 1) {
      throw new EOFException();
    }
    totalRead+=read;
  }
  short result=(short)((shortBuf[1] & 0xff) << 8);
  result|=(shortBuf[0] & 0xff);
  return result;
}
 

Example 26

From project erjang, under directory /src/main/java/erjang/.

Source file: EInputStream.java

  17 
vote

public void readFully(byte[] b) throws IOException {
  int pos=0;
  while (pos < b.length) {
    int read;
    try {
      read=super.read(b,pos,b.length - pos);
    }
 catch (    IndexOutOfBoundsException ioobe) {
      read=0;
    }
    if (read == 0)     throw new EOFException("Can't read enough from input stream");
    pos+=read;
  }
}
 

Example 27

From project Flume-Hive, under directory /src/java/com/cloudera/util/.

Source file: ByteBufferInputStream.java

  17 
vote

@Override public int read() throws IOException {
  try {
    return buf.get();
  }
 catch (  BufferUnderflowException e) {
    throw new EOFException();
  }
}
 

Example 28

From project flume-syslog-source2, under directory /src/main/java/com/spotify/flume/syslog2/.

Source file: SyslogParser.java

  17 
vote

/** 
 * Read the next byte.
 * @param checkEof true to throw EOFException on EOF, false to return -1.
 * @return the byte, or -1 on EOF.
 */
private int read(boolean checkEof) throws IOException {
  if (pushBack != -1) {
    int c=pushBack;
    pushBack=-1;
    return c;
  }
  int c=in.read();
  if (checkEof && c == -1)   throw new EOFException("Unexpected end of syslog stream");
  return c;
}
 

Example 29

From project flume_1, under directory /flume-core/src/main/java/com/cloudera/util/.

Source file: ByteBufferInputStream.java

  17 
vote

@Override public int read() throws IOException {
  try {
    return buf.get();
  }
 catch (  BufferUnderflowException e) {
    throw new EOFException();
  }
}
 

Example 30

From project galaxy, under directory /src/co/paralleluniverse/common/io/.

Source file: ByteBufferInputStream.java

  17 
vote

@Override public boolean readBoolean() throws IOException {
  try {
    return buffer.get() != 0;
  }
 catch (  BufferUnderflowException e) {
    throw new EOFException();
  }
}
 

Example 31

From project gmarks-android, under directory /src/main/java/org/thomnichols/android/gmarks/thirdparty/.

Source file: IOUtils.java

  17 
vote

/** 
 * Skip the requested number of bytes or fail if there are not enough left. <p> This allows for the possibility that  {@link InputStream#skip(long)} maynot skip as many bytes as requested (most likely because of reaching EOF).
 * @param input stream to skip
 * @param toSkip the number of bytes to skip
 * @see InputStream#skip(long)
 * @throws IOException if there is a problem reading the file
 * @throws IllegalArgumentException if toSkip is negative
 * @throws EOFException if the number of bytes skipped was incorrect 
 * @since Commons IO 2.0
 */
public static void skipFully(InputStream input,long toSkip) throws IOException {
  if (toSkip < 0) {
    throw new IllegalArgumentException("Bytes to skip must not be negative: " + toSkip);
  }
  long skipped=skip(input,toSkip);
  if (skipped != toSkip) {
    throw new EOFException("Bytes to skip: " + toSkip + " actual: "+ skipped);
  }
}
 

Example 32

From project android_8, under directory /src/com/google/gson/stream/.

Source file: JsonReader.java

  16 
vote

private int nextNonWhitespace() throws IOException {
  while (pos < limit || fillBuffer(1)) {
    int c=buffer[pos++];
switch (c) {
case '\t':
case ' ':
case '\n':
case '\r':
      continue;
case '/':
    if (pos == limit && !fillBuffer(1)) {
      return c;
    }
  checkLenient();
char peek=buffer[pos];
switch (peek) {
case '*':
pos++;
if (!skipTo("*/")) {
throw syntaxError("Unterminated comment");
}
pos+=2;
continue;
case '/':
pos++;
skipToEndOfLine();
continue;
default :
return c;
}
case '#':
checkLenient();
skipToEndOfLine();
continue;
default :
return c;
}
}
throw new EOFException("End of input");
}
 

Example 33

From project behemoth, under directory /io/src/main/java/com/digitalpebble/behemoth/io/warc/.

Source file: HttpResponse.java

  16 
vote

private static int readLine(PushbackInputStream in,StringBuffer line,boolean allowContinuedLine) throws IOException {
  line.setLength(0);
  for (int c=in.read(); c != -1; c=in.read()) {
switch (c) {
case '\r':
      if (peek(in) == '\n') {
        in.read();
      }
case '\n':
    if (line.length() > 0) {
      if (allowContinuedLine) switch (peek(in)) {
case ' ':
case '\t':
        in.read();
      continue;
  }
}
return line.length();
default :
line.append((char)c);
}
}
throw new EOFException();
}
 

Example 34

From project blacktie, under directory /jatmibroker-xatmi/src/main/java/org/jboss/narayana/blacktie/jatmibroker/core/transport/hybrid/stomp/.

Source file: StompManagement.java

  16 
vote

private static String readLine(InputStream inputStream) throws IOException {
  String toReturn=null;
  char[] read=new char[0];
  char c=(char)inputStream.read();
  while (c != '\n' && c != '\000' && c != -1) {
    char[] tmp=new char[read.length + 1];
    System.arraycopy(read,0,tmp,0,read.length);
    tmp[read.length]=c;
    read=tmp;
    c=(char)inputStream.read();
  }
  if (c == -1) {
    throw new EOFException("Read the end of the stream");
  }
  if (c == '\000') {
    log.trace("returning null");
  }
 else {
    toReturn=new String(read);
    log.trace("returning: " + toReturn);
  }
  return toReturn;
}
 

Example 35

From project CircDesigNA, under directory /src/org/apache/commons/math/.

Source file: MathRuntimeException.java

  16 
vote

/** 
 * Constructs a new <code>EOFException</code> with specified formatted detail message. Message formatting is delegated to  {@link java.text.MessageFormat}.
 * @param pattern format specifier
 * @param arguments format arguments
 * @return built exception
 * @since 2.2
 */
public static EOFException createEOFException(final Localizable pattern,final Object... arguments){
  return new EOFException(){
    /** 
 * Serializable version identifier. 
 */
    private static final long serialVersionUID=6067985859347601503L;
    /** 
 * {@inheritDoc} 
 */
    @Override public String getMessage(){
      return buildMessage(Locale.US,pattern,arguments);
    }
    /** 
 * {@inheritDoc} 
 */
    @Override public String getLocalizedMessage(){
      return buildMessage(Locale.getDefault(),pattern,arguments);
    }
  }
;
}
 

Example 36

From project accent, under directory /src/main/java/net/lshift/accent/.

Source file: ExceptionUtils.java

  15 
vote

/** 
 * Determines whether a given shutdown reason is recoverable.
 * @param s the shutdown signal to inspect.
 * @return true - the shutdown is recoverable; false - it isn't.
 */
public static boolean isShutdownRecoverable(ShutdownSignalException s){
  if (s != null) {
    int replyCode=getReplyCode(s);
    return s.isInitiatedByApplication() && ((replyCode == AMQP.CONNECTION_FORCED) || (replyCode == AMQP.INTERNAL_ERROR) || s instanceof AlreadyClosedException|| (s.getCause() instanceof EOFException));
  }
  return false;
}
 

Example 37

From project airlift, under directory /jaxrs/src/main/java/io/airlift/jaxrs/.

Source file: JsonMapper.java

  15 
vote

public Object readFrom(Class<Object> type,Type genericType,Annotation[] annotations,MediaType mediaType,MultivaluedMap<String,String> httpHeaders,InputStream inputStream) throws IOException {
  Object object;
  try {
    JsonParser jsonParser=objectMapper.getJsonFactory().createJsonParser(inputStream);
    jsonParser.disable(JsonParser.Feature.AUTO_CLOSE_SOURCE);
    object=objectMapper.readValue(jsonParser,TypeFactory.type(genericType));
  }
 catch (  Exception e) {
    if (e instanceof IOException && !(e instanceof JsonProcessingException) && !(e instanceof EOFException)) {
      throw (IOException)e;
    }
    log.debug(e,"Invalid json for Java type %s",type);
    throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST).entity("Invalid json for Java type " + type).build());
  }
  Set<ConstraintViolation<Object>> violations=VALIDATOR.validate(object);
  if (!violations.isEmpty()) {
    throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST).entity(messagesFor(violations)).build());
  }
  return object;
}
 

Example 38

From project akela, under directory /src/main/java/com/mozilla/pig/eval/json/.

Source file: JsonMap.java

  15 
vote

public Map<String,Object> exec(Tuple input) throws IOException {
  if (input == null || input.size() == 0) {
    return null;
  }
  try {
    Map<String,Object> values=jsonMapper.readValue((String)input.get(0),new TypeReference<Map<String,Object>>(){
    }
);
    return makeSafe(values);
  }
 catch (  JsonParseException e) {
    warn("JSON Parse Error: " + e.getMessage(),ERRORS.JSONParseError);
  }
catch (  JsonMappingException e) {
    warn("JSON Mapping Error: " + e.getMessage(),ERRORS.JSONMappingError);
  }
catch (  EOFException e) {
    warn("Hit EOF unexpectedly",ERRORS.EOFError);
  }
catch (  Exception e) {
    warn("Generic error during JSON mapping",ERRORS.GenericError);
  }
  return null;
}
 

Example 39

From project beanmill_1, under directory /src/main/java/com/traxel/lumbermill/event/.

Source file: EventListenerClient.java

  15 
vote

/** 
 * ----------------------------------------------- Instance API -----------------------------------------------
 * @return  DOCUMENT ME!
 * @throws SocketException  DOCUMENT ME!
 */
private Object readObject() throws SocketException {
  Object o=null;
  try {
    o=STREAM.readObject();
  }
 catch (  EOFException e) {
    close();
  }
catch (  SocketException e) {
    throw e;
  }
catch (  IOException e) {
    e.printStackTrace();
  }
catch (  ClassNotFoundException e) {
    e.printStackTrace();
  }
  return o;
}
 

Example 40

From project chukwa, under directory /src/test/java/org/apache/hadoop/chukwa/validationframework/util/.

Source file: DataOperations.java

  15 
vote

public static void extractRawLogFromDump(String directory,String fileName) throws Exception {
  File inputFile=new File(directory + fileName + ".bin");
  File outputFile=new File(directory + fileName + ".raw");
  DataInputStream dis=new DataInputStream(new FileInputStream(inputFile));
  Chunk chunk=null;
  FileWriter out=new FileWriter(outputFile);
  boolean eof=false;
  do {
    try {
      chunk=ChunkImpl.read(dis);
      out.write(new String(chunk.getData()));
    }
 catch (    EOFException e) {
      eof=true;
    }
  }
 while (!eof);
  dis.close();
  out.close();
}
 

Example 41

From project CIShell, under directory /templates/org.cishell.templates/src/org/cishell/templates/staticexecutable/.

Source file: StaticExecutableRunner.java

  15 
vote

protected StringBuffer logStream(int logLevel,InputStream is,StringBuffer buffer) throws AlgorithmExecutionException {
  try {
    int available=is.available();
    if (available > 0) {
      byte[] b=new byte[available];
      is.read(b);
      buffer.append(new String(b));
      buffer=log(logLevel,buffer);
    }
  }
 catch (  EOFException e) {
  }
catch (  IOException e) {
    throw new AlgorithmExecutionException("Error when processing the algorithm's screen output",e);
  }
  return buffer;
}
 

Example 42

From project connectbot, under directory /src/net/sourceforge/jsocks/.

Source file: ProxyServer.java

  15 
vote

private void onBind(ProxyMessage msg) throws IOException {
  ProxyMessage response=null;
  if (proxy == null)   ss=new ServerSocket(0);
 else   ss=new SocksServerSocket(proxy,msg.ip,msg.port);
  ss.setSoTimeout(acceptTimeout);
  log("Trying accept on " + ss.getInetAddress() + ":"+ ss.getLocalPort());
  if (msg.version == 5)   response=new Socks5Message(Proxy.SOCKS_SUCCESS,ss.getInetAddress(),ss.getLocalPort());
 else   response=new Socks4Message(Socks4Message.REPLY_OK,ss.getInetAddress(),ss.getLocalPort());
  response.write(out);
  mode=ACCEPT_MODE;
  pipe_thread1=Thread.currentThread();
  pipe_thread2=new Thread(this);
  pipe_thread2.start();
  sock.setSoTimeout(0);
  int eof=0;
  try {
    while ((eof=in.read()) >= 0) {
      if (mode != ACCEPT_MODE) {
        if (mode != PIPE_MODE)         return;
        remote_out.write(eof);
        break;
      }
    }
  }
 catch (  EOFException eofe) {
    return;
  }
catch (  InterruptedIOException iioe) {
    if (mode != PIPE_MODE)     return;
  }
 finally {
  }
  if (eof < 0)   return;
  pipe(in,remote_out);
}
 

Example 43

From project crash, under directory /shell/telnet/src/main/java/org/crsh/telnet/term/.

Source file: TelnetIO.java

  15 
vote

public int read() throws IOException {
  try {
    return termIO.read();
  }
 catch (  EOFException e) {
    return TerminalIO.HANDLED;
  }
catch (  SocketException e) {
    return TerminalIO.HANDLED;
  }
}
 

Example 44

From project crawler4j, under directory /src/main/java/edu/uci/ics/crawler4j/fetcher/.

Source file: PageFetchResult.java

  15 
vote

public void discardContentIfNotConsumed(){
  try {
    if (entity != null) {
      EntityUtils.consume(entity);
    }
  }
 catch (  EOFException e) {
  }
catch (  IOException e) {
  }
catch (  Exception e) {
    e.printStackTrace();
  }
}
 

Example 45

From project dawn-isencia, under directory /com.isencia.passerelle.commons.ume/src/main/java/com/isencia/message/extractor/.

Source file: EndOfMsgCharMsgExtractor.java

  15 
vote

/** 
 * @return
 * @throws EndOfDataException
 * @throws Exception
 */
private char readNextChar() throws EndOfDataException, Exception {
  try {
    int res=reader.read();
    if (res == -1) {
      throw new EndOfDataException();
    }
    if (res == endOfMsgChar)     throw new EndOfDataException();
    return (char)res;
  }
 catch (  EOFException e) {
    throw new EndOfDataException(e.getMessage());
  }
catch (  IOException e) {
    throw new EndOfDataException(e.getMessage());
  }
catch (  NullPointerException e) {
    throw new Exception("No reader specified");
  }
}
 

Example 46

From project des, under directory /daemon/lib/apache-log4j-1.2.16/src/main/java/org/apache/log4j/chainsaw/.

Source file: LoggingReceiver.java

  15 
vote

/** 
 * loops getting the events 
 */
public void run(){
  LOG.debug("Starting to get data");
  try {
    final ObjectInputStream ois=new ObjectInputStream(mClient.getInputStream());
    while (true) {
      final LoggingEvent event=(LoggingEvent)ois.readObject();
      mModel.addEvent(new EventDetails(event));
    }
  }
 catch (  EOFException e) {
    LOG.info("Reached EOF, closing connection");
  }
catch (  SocketException e) {
    LOG.info("Caught SocketException, closing connection");
  }
catch (  IOException e) {
    LOG.warn("Got IOException, closing connection",e);
  }
catch (  ClassNotFoundException e) {
    LOG.warn("Got ClassNotFoundException, closing connection",e);
  }
  try {
    mClient.close();
  }
 catch (  IOException e) {
    LOG.warn("Error closing connection",e);
  }
}
 

Example 47

From project DirectMemory, under directory /DirectMemory-Cache/src/main/java/org/apache/directmemory/cache/.

Source file: CacheServiceImpl.java

  15 
vote

@Override public V retrieve(K key){
  Pointer<V> ptr=getPointer(key);
  if (ptr == null) {
    return null;
  }
  if (ptr.isExpired() || ptr.isFree()) {
    map.remove(key);
    if (!ptr.isFree()) {
      memoryManager.free(ptr);
    }
    return null;
  }
 else {
    try {
      return serializer.deserialize(memoryManager.retrieve(ptr),ptr.getClazz());
    }
 catch (    EOFException e) {
      logger.error(e.getMessage());
    }
catch (    IOException e) {
      logger.error(e.getMessage());
    }
catch (    ClassNotFoundException e) {
      logger.error(e.getMessage());
    }
catch (    InstantiationException e) {
      logger.error(e.getMessage());
    }
catch (    IllegalAccessException e) {
      logger.error(e.getMessage());
    }
  }
  return null;
}
 

Example 48

From project fast-http, under directory /src/main/java/org/neo4j/smack/serialization/.

Source file: JsonDeserializer.java

  15 
vote

@Override public Object readObject(){
  try {
    return parser.readValueAs(Object.class);
  }
 catch (  EOFException e) {
    return null;
  }
catch (  JsonParseException e) {
    throw new DeserializationException("Invalid JSON format, expected object.",e);
  }
catch (  IOException e) {
    throw new DeserializationException("Unable to read expected object value.",e);
  }
}
 

Example 49

From project flume, under directory /flume-ng-channels/flume-file-channel/src/main/java/org/apache/flume/channel/file/.

Source file: LogFile.java

  15 
vote

/** 
 * Construct a Sequential Log Reader object
 * @param file
 * @throws IOException if an I/O error occurs
 * @throws EOFException if the file is empty
 */
SequentialReader(File file,@Nullable KeyProvider encryptionKeyProvider) throws IOException, EOFException {
  this.file=file;
  this.encryptionKeyProvider=encryptionKeyProvider;
  fileHandle=new RandomAccessFile(file,"r");
  fileChannel=fileHandle.getChannel();
}