Java Code Examples for org.apache.commons.fileupload.FileItemStream#ItemSkippedException

The following examples show how to use org.apache.commons.fileupload.FileItemStream#ItemSkippedException . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultipartStreamCopy.java    From dcs-sdk-java with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the next byte in the stream.
 *
 * @return The next byte in the stream, as a non-negative
 * integer, or -1 for EOF.
 * @throws IOException An I/O error occurred.
 */
@Override
public int read() throws IOException {
    if (closed) {
        throw new FileItemStream.ItemSkippedException();
    }
    if (available() == 0 && makeAvailable() == 0) {
        return -1;
    }
    ++total;
    int b = buffer[head++];
    if (b >= 0) {
        return b;
    }
    return b + BYTE_POSITIVE_OFFSET;
}
 
Example 2
Source File: MultipartStreamCopy.java    From dcs-sdk-java with Apache License 2.0 6 votes vote down vote up
/**
 * Reads bytes into the given buffer.
 *
 * @param b   The destination buffer, where to write to.
 * @param off Offset of the first byte in the buffer.
 * @param len Maximum number of bytes to read.
 * @return Number of bytes, which have been actually read,
 * or -1 for EOF.
 * @throws IOException An I/O error occurred.
 */
@Override
public int read(byte[] b, int off, int len) throws IOException {
    if (closed) {
        throw new FileItemStream.ItemSkippedException();
    }
    if (len == 0) {
        return 0;
    }
    int res = available();
    if (res == 0) {
        res = makeAvailable();
        if (res == 0) {
            return -1;
        }
    }
    res = Math.min(res, len);
    System.arraycopy(buffer, head, b, off, res);
    head += res;
    total += res;
    return res;
}
 
Example 3
Source File: MultipartStreamCopy.java    From dcs-sdk-java with Apache License 2.0 6 votes vote down vote up
/**
 * Skips the given number of bytes.
 *
 * @param bytes Number of bytes to skip.
 * @return The number of bytes, which have actually been
 * skipped.
 * @throws IOException An I/O error occurred.
 */
@Override
public long skip(long bytes) throws IOException {
    if (closed) {
        throw new FileItemStream.ItemSkippedException();
    }
    int av = available();
    if (av == 0) {
        av = makeAvailable();
        if (av == 0) {
            return 0;
        }
    }
    long res = Math.min(av, bytes);
    head += res;
    return res;
}
 
Example 4
Source File: MultipartStream.java    From actframework with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the next byte in the stream.
 * @return The next byte in the stream, as a non-negative
 *   integer, or -1 for EOF.
 * @throws IOException An I/O error occurred.
 */
public int read() throws IOException {
    if (closed) {
        throw new FileItemStream.ItemSkippedException();
    }
    if (available() == 0) {
        if (makeAvailable() == 0) {
            return -1;
        }
    }
    ++total;
    int b = buffer[head++];
    if (b >= 0) {
        return b;
    }
    return b + BYTE_POSITIVE_OFFSET;
}
 
Example 5
Source File: MultipartStream.java    From actframework with Apache License 2.0 6 votes vote down vote up
/**
 * Reads bytes into the given buffer.
 * @param b The destination buffer, where to write to.
 * @param off Offset of the first byte in the buffer.
 * @param len Maximum number of bytes to read.
 * @return Number of bytes, which have been actually read,
 *   or -1 for EOF.
 * @throws IOException An I/O error occurred.
 */
public int read(byte[] b, int off, int len) throws IOException {
    if (closed) {
        throw new FileItemStream.ItemSkippedException();
    }
    if (len == 0) {
        return 0;
    }
    int res = available();
    if (res == 0) {
        res = makeAvailable();
        if (res == 0) {
            return -1;
        }
    }
    res = Math.min(res, len);
    System.arraycopy(buffer, head, b, off, res);
    head += res;
    total += res;
    return res;
}
 
Example 6
Source File: MultipartStream.java    From actframework with Apache License 2.0 6 votes vote down vote up
/**
 * Skips the given number of bytes.
 * @param bytes Number of bytes to skip.
 * @return The number of bytes, which have actually been
 *   skipped.
 * @throws IOException An I/O error occurred.
 */
public long skip(long bytes) throws IOException {
    if (closed) {
        throw new FileItemStream.ItemSkippedException();
    }
    int av = available();
    if (av == 0) {
        av = makeAvailable();
        if (av == 0) {
            return 0;
        }
    }
    long res = Math.min(av, bytes);
    head += res;
    return res;
}
 
Example 7
Source File: MultipartStream.java    From restcommander with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the next byte in the stream.
 * @return The next byte in the stream, as a non-negative
 *   integer, or -1 for EOF.
 * @throws IOException An I/O error occurred.
 */
public int read() throws IOException {
    if (closed) {
        throw new FileItemStream.ItemSkippedException();
    }
    if (available() == 0) {
        if (makeAvailable() == 0) {
            return -1;
        }
    }
    ++total;
    int b = buffer[head++];
    if (b >= 0) {
        return b;
    }
    return b + BYTE_POSITIVE_OFFSET;
}
 
Example 8
Source File: MultipartStream.java    From restcommander with Apache License 2.0 6 votes vote down vote up
/**
 * Reads bytes into the given buffer.
 * @param b The destination buffer, where to write to.
 * @param off Offset of the first byte in the buffer.
 * @param len Maximum number of bytes to read.
 * @return Number of bytes, which have been actually read,
 *   or -1 for EOF.
 * @throws IOException An I/O error occurred.
 */
public int read(byte[] b, int off, int len) throws IOException {
    if (closed) {
        throw new FileItemStream.ItemSkippedException();
    }
    if (len == 0) {
        return 0;
    }
    int res = available();
    if (res == 0) {
        res = makeAvailable();
        if (res == 0) {
            return -1;
        }
    }
    res = Math.min(res, len);
    System.arraycopy(buffer, head, b, off, res);
    head += res;
    total += res;
    return res;
}
 
Example 9
Source File: MultipartStream.java    From restcommander with Apache License 2.0 6 votes vote down vote up
/**
 * Skips the given number of bytes.
 * @param bytes Number of bytes to skip.
 * @return The number of bytes, which have actually been
 *   skipped.
 * @throws IOException An I/O error occurred.
 */
public long skip(long bytes) throws IOException {
    if (closed) {
        throw new FileItemStream.ItemSkippedException();
    }
    int av = available();
    if (av == 0) {
        av = makeAvailable();
        if (av == 0) {
            return 0;
        }
    }
    long res = Math.min(av, bytes);
    head += res;
    return res;
}