List of usage examples for java.io EOFException EOFException
public EOFException()
EOFException
with null
as its error detail message. From source file:org.anarres.lzo.LzoInputStream.java
protected void readBytes(byte[] buf, int off, int length) throws IOException { while (length > 0) { int count = in.read(buf, off, length); if (count < 0) throw new EOFException(); off += count;// ww w . j a v a2 s . co m length -= count; } }
From source file:org.bndtools.rt.repository.server.RepositoryResourceComponent.java
private static int readUByte(InputStream in) throws IOException { int b = in.read(); if (b == -1) { throw new EOFException(); }/* ww w . j ava2s. com*/ if (b < -1 || b > 255) { // Report on this.in, not argument in; see read{Header, Trailer}. throw new IOException(in.getClass().getName() + ".read() returned value out of range -1..255: " + b); } return b; }
From source file:com.icloud.framework.core.util.FBUtilities.java
/** @return null */ public static byte[] skipShortByteArray(DataInput in) throws IOException { int skip = readShortLength(in); while (skip > 0) { int skipped = in.skipBytes(skip); if (skipped == 0) throw new EOFException(); skip -= skipped;//from w ww . j a v a 2 s . c o m } return null; }
From source file:wordnice.api.Nice.java
public static EOFException eof() { return new EOFException(); }
From source file:org.apache.htrace.core.LocalFileSpanReceiver.java
public static String getUniqueLocalTraceFileName() { String tmp = System.getProperty("java.io.tmpdir", "/tmp"); String nonce = null;//from w w w .j a va 2s. c o m BufferedReader reader = null; try { // On Linux we can get a unique local file name by reading the process id // out of /proc/self/stat. (There isn't any portable way to get the // process ID from Java.) reader = new BufferedReader(new InputStreamReader(new FileInputStream("/proc/self/stat"), "UTF-8")); String line = reader.readLine(); if (line == null) { throw new EOFException(); } nonce = line.split(" ")[0]; } catch (IOException e) { } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { LOG.warn("Exception in closing " + reader, e); } } } if (nonce == null) { // If we can't use the process ID, use a random nonce. nonce = UUID.randomUUID().toString(); } return new File(tmp, nonce).getAbsolutePath(); }
From source file:IOUtilities.java
/** * Reads the specified amount of bytes from the specified input stream and * returns the resulting array. Throws an <code>EOFException</code> if the * stream ends before the specified amount of bytes is read. *///from w w w .j a v a2s . co m public static byte[] read(InputStream in, int amount) throws IOException { ByteArrayOutputStream buf = new ByteArrayOutputStream(amount); if (pump(in, buf, amount) != amount) throw new EOFException(); return buf.toByteArray(); }
From source file:org.apache.openejb.math.MathRuntimeException.java
/** * Constructs a new <code>EOFException</code> with specified formatted detail message. * Message formatting is delegated to {@link MessageFormat}. * * @param pattern format specifier//from ww w . j a v a2s. com * @param arguments format arguments * @return built exception */ public static EOFException createEOFException(final String pattern, final Object... arguments) { return new EOFException() { /** Serializable version identifier. */ private static final long serialVersionUID = 279461544586092584L; /** {@inheritDoc} */ @Override public String getMessage() { return buildMessage(Locale.US, pattern, arguments); } /** {@inheritDoc} */ @Override public String getLocalizedMessage() { return buildMessage(Locale.getDefault(), pattern, arguments); } }; }
From source file:com.bittorrent.mpetazzoni.bencode.BDecoder.java
/** * Returns the next byte read from the InputStream (as int). * * @throws EOFException If InputStream.read() returned -1. *//* ww w . j a va 2 s .c om*/ private int read() throws IOException { int c = this.in.read(); if (c == -1) throw new EOFException(); return c; }
From source file:UTF8Util.java
/** Read an unsigned byte from an InputStream, throwing an EOFException if the end of the input is reached./*from w ww . j a va2 s . co m*/ @exception IOException if an I/O error occurs. @exception EOFException if the end of the stream is reached @see DataInput#readUnsignedByte */ public static int readUnsignedByte(InputStream in) throws IOException { int b = in.read(); if (b < 0) throw new EOFException(); return b; }
From source file:ga.rugal.jpt.common.tracker.bcodec.BDecoder.java
/** * Returns the next byte read from the InputStream (as int). * * @throws EOFException If InputStream.read() returned -1. *///from ww w. j a v a2 s. c om private int read() throws IOException { int c = this.in.read(); if (c == -1) { throw new EOFException(); } return c; }