Using buffered boundary stream in multipart parser. But currently not working

This commit is contained in:
Ziver Koc 2016-07-08 16:23:29 +02:00
parent 53dec4603c
commit 077963ae28
11 changed files with 198 additions and 152 deletions

View file

@ -216,9 +216,9 @@ public class BufferedBoundaryInputStream extends FilterInputStream{
}
/**
* @return if current position in the buffer is a boundary
* @return if there is more data to read
*/
public boolean isBoundary(){
public boolean hasNext(){
return bound_pos == buf_pos;
}

View file

@ -89,11 +89,23 @@ public class IOUtil {
}
/**
* Copies all data from the input stream to the output stream.
* The input stream will not be closed after method has returned.
* Copies all data from one InputStream to another OutputStream.
* The streams will not be closed after method has returned.
*/
public static void copyStream(InputStream in, OutputStream out) throws IOException {
byte[] buff = new byte[256];
byte[] buff = new byte[8192]; // This is the default BufferedInputStream buffer size
int len;
while((len = in.read(buff)) > 0){
out.write(buff, 0, len);
}
}
/**
* Copies all data from one Reader to another Writer.
* The streams will not be closed after method has returned.
*/
public static void copyStream(Reader in, Writer out) throws IOException {
char[] buff = new char[8192]; // This is the default BufferedReader buffer size
int len;
while((len = in.read(buff)) > 0){
out.write(buff, 0, len);

View file

@ -0,0 +1,20 @@
package zutil.io;
import java.io.OutputStream;
/**
* An OutputStream that does nothing but discard data. Similar to /dev/null
*
* Created by Ziver on 2016-07-08.
*/
public class NullOutputStream extends OutputStream {
@Override
public void write(int b) { }
@Override
public void write(byte b[]) { }
@Override
public void write(byte b[], int off, int len) { }
}

41
src/zutil/io/NullWriter.java Executable file
View file

@ -0,0 +1,41 @@
package zutil.io;
import java.io.IOException;
import java.io.Writer;
/**
* An Writer that does nothing but discard data. Similar to /dev/null
*
* Created by Ziver on 2016-07-08.
*/
public class NullWriter extends Writer{
@Override
public void write(int c) { }
@Override
public void write(char cbuf[]) { }
@Override
public void write(char cbuf[], int off, int len) { }
@Override
public void write(String str) throws IOException { }
@Override
public void write(String str, int off, int len) { }
@Override
public Writer append(CharSequence csq) {
return this;
}
@Override
public Writer append(CharSequence csq, int start, int end) {
return this;
}
@Override
public Writer append(char c) {
return this;
}
@Override
public void flush() { }
@Override
public void close() { };
}