Issue #367 Search in memory: save(export) SWFs

few refactorings
This commit is contained in:
Jindra Petk
2013-09-10 07:46:16 +02:00
parent 9696b91d4d
commit 17a5e75f1a
17 changed files with 133 additions and 48 deletions

View File

@@ -0,0 +1,38 @@
package com.jpexs.helpers;
import java.io.IOException;
import java.io.InputStream;
/**
*
* @author JPEXS
*/
public class LimitedInputStream extends InputStream {
private InputStream is;
private long pos = 0;
private long limit;
public LimitedInputStream(InputStream is, long limit) {
this.is = is;
this.limit = limit;
}
@Override
public int read() throws IOException {
if (pos >= limit) {
return -1;
}
pos++;
return is.read();
}
@Override
public int available() throws IOException {
int avail = is.available();
if (pos + avail > limit) {
avail = (int)(limit - pos);
}
return avail;
}
}