Package sun.net.www.http
Class PosterOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.ByteArrayOutputStream
-
- sun.net.www.http.PosterOutputStream
-
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
public class PosterOutputStream extends ByteArrayOutputStream
Instances of this class are returned to applications for the purpose of sending user data for a HTTP POST or PUT request. This class is used when the content-length will be specified in the header of the request. The semantics of ByteArrayOutputStream are extended so that when close() is called, it is no longer possible to write additional data to the stream. From this point the content length of the request is fixed and cannot change.
-
-
Field Summary
-
Fields inherited from class java.io.ByteArrayOutputStream
buf, count
-
-
Constructor Summary
Constructors Constructor Description PosterOutputStream()Creates a new output stream for POST user data
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()After close() has been called, it is no longer possible to write to this stream.voidreset()Resets thecountfield of this output stream to zero, so that all currently accumulated output in the ouput stream is discarded.voidwrite(byte[] b, int off, int len)Writeslenbytes from the specified byte array starting at offsetoffto this output stream.voidwrite(int b)Writes the specified byte to this output stream.-
Methods inherited from class java.io.ByteArrayOutputStream
size, toByteArray, toString, writeTo
-
Methods inherited from class java.io.OutputStream
flush, write
-
-
-
-
Method Detail
-
write
public void write(int b)
Writes the specified byte to this output stream.- Overrides:
writein classByteArrayOutputStream- Parameters:
b- the byte to be written.
-
write
public void write(byte[] b, int off, int len)Writeslenbytes from the specified byte array starting at offsetoffto this output stream.- Overrides:
writein classByteArrayOutputStream- Parameters:
b- the data.off- the start offset in the data.len- the number of bytes to write.
-
reset
public void reset()
Resets thecountfield of this output stream to zero, so that all currently accumulated output in the ouput stream is discarded. The output stream can be used again, reusing the already allocated buffer space. If the output stream has been closed, then this method has no effect.- Overrides:
resetin classByteArrayOutputStream- See Also:
ByteArrayInputStream.count
-
close
public void close() throws IOExceptionAfter close() has been called, it is no longer possible to write to this stream. Further calls to write will have no effect.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classByteArrayOutputStream- Throws:
IOException- if an I/O error occurs.
-
-