11package com .conveyal .r5 .analyst .progress ;
22
33import com .conveyal .file .FileUtils ;
4- import org .apache .commons .fileupload .FileItem ;
54import org .apache .commons .io .input .ProxyInputStream ;
65
76import java .io .File ;
1514 * This will report progress as the total number of bytes that have passed through the stream, like CountingInputStream.
1615 * This can exceed 100% of the file size if the caller uses mark and reset. The progressListener should be
1716 * pre-configured with the total number of bytes expected and a detail message using ProgressListener::beginTask.
18- * The static method forFileItem () demonstrates usage when reading from a file of known length.
17+ * The static method forFile () demonstrates usage when reading from a file of known length.
1918 */
2019public class ProgressInputStream extends ProxyInputStream {
2120
@@ -40,22 +39,6 @@ public synchronized long skip (final long length) throws IOException {
4039 return skippedBytes ;
4140 }
4241
43- /**
44- * Given an uploaded file, report progress on reading it.
45- * Incrementing the progress seems to introduce some inefficiency when performing unbuffered small reads, such as
46- * calls to InputStream.read() which are used by DataInputStream to read numbers.
47- * TODO wrap in buffered input stream to reduce small read calls, or tune to only report once per percentage?
48- */
49- public static ProgressInputStream forFileItem (FileItem fileItem , ProgressListener progressListener ) {
50- try {
51- checkArgument (fileItem .getSize () < Integer .MAX_VALUE );
52- progressListener .beginTask ("Reading file " + fileItem .getName (), (int )(fileItem .getSize ()));
53- return new ProgressInputStream (progressListener , fileItem .getInputStream ());
54- } catch (IOException e ) {
55- throw new RuntimeException (e );
56- }
57- }
58-
5942 /**
6043 * Given an uploaded file, report progress on reading it.
6144 */
0 commit comments