|
![]() |
InputStream
and OutputStream
are the
abstract ancestors of all I-O streams.
void close() void flush()
abstract void write(int b)
void write(byte [] b) void write(byte [] b, int off, int len)
int available()
void close() long skip(long n)
abstract int read()
int read(byte [] b) int read(byte [] b, int off, int len)
void mark(int readlimit) void reset() boolean markSupported()
Input
- and OutputStream
s.
ByteArrayInputStream
: read bytes from an array.
ByteArrayInputStream(byte [] buff)
FileInputStream
: read bytes from a file.
FileInputStream(File file) FileInputStream(String name)
AudioInputStream
: read encoded audio frames.
AudioInputStream(InputStream is, AudioFormat fmt, long len)
ByteArrayOutputStream
: write bytes to an array.
ByteArrayOutputStream()
FileOutputStream
: write bytes to a file.
FileOutputStream(File file) FileOutputStream( File file, boolean append) FileOutputStream(String name) FileOutputStream( String name, boolean append)
BufferedInputStream
: allow buffering, suportmark()
andreset()
.
CheckedInputStream
: compute a checksum.
CipherInputStream
: decrypt the bytes.
ProgressMonitorInputStream
: show read progress.
PushbackInputStream
: push-back bytes.
import javax.crypto.CipherInputStream
; import javax.crypto.Cipher
; import java.io.InputStream
; import java.io.BufferedInputStream
; import java.io.FileInputStream
; import java.io.FileNotFoundException
; import java.io.IOException
; void seekritRead(String filename, Cipher cipher) throws FileNotFoundException, IOException { finalInputStream
inputStream = new CipherInputStream( new BufferedInputStream( new FileInputStream(filename)), cipher); // blah blah blah inputStream.close(); }
BufferedOutputStream
: allow buffering.
CheckedOutputStream
: compute a checksum.
CipherOutputStream
: encrypt the bytes.
PrintStream
: output formatted data.
boolean
,byte
,short
,char
,int
,long
,float
, anddouble
.
writeBoolean(boolean)()
,writeByte()
, …
DataInput
and DataOutput
interface documentation for details.
DataInputStream
and DataOutputStream
implement the Data I-O interfaces.
final DataOutputStream outputStream = new DataOutputStream( new BufferedOutputStream( new FileOutputStream(filename))) outputStream.writeLong(checksum)
Reader
and Writer
are the abstract
ancestors of text-based I-O streams.
void close() void flush()
void write(int c) void write(char [] b) void write(string s)
BufferedWriter
: write characters to a buffer.
CharArrayWriter
: write characters to an array.
OutputStreamWriter
: write characters to an output
stream.
FileWriter
.
PrintWriter
: write textual representations of values.
StringWriter
: write characters to a string buffer.
void mark(int n) void reset() int read() int read(char[] cbuf) abstract int read( char[] cbuf, int off, int len)
BufferedReader
: read characters with buffering.
CharArrayReader
: read characters from an array.
InputStreamWriter
: read characters from an input
stream.
FileReader
.
StringReader
: read characters from a string buffer.
PrintWriter
translates binary values to a textual representation.
Scanner
class provides a simple text parser and
translator.
Scanner(Reader source) double nextDouble() short nextShort(int radix) String nextLine()
Charset
class is responsible for the translation
between encodings.
static SortedMap availableCharsets() static Charset forName(String name) ByteBuffer encode(String str) CharBuffer decode(ByteBuffer buffer)