In order to read/ write into or from files java provides basically three ways
- Reading /Writing bytes
- Reading/ Writing Characters
- Reading/ Writing Primitive data
Method
|
Description
|
int read(byte[]
b)
|
It is used to
read the number of bytes from the input stream.
|
int read(byte[]
b, int off, int len)
|
It is used to
read len bytes of
data from the input stream.
|
int readInt()
|
It is used to
read input bytes and return an int value.
|
byte readByte()
|
It is used to
read and return the one input byte.
|
char readChar()
|
It is used to
read two input bytes and returns a char value.
|
double
readDouble()
|
It is used to
read eight input bytes and returns a double value.
|
boolean
readBoolean()
|
It is used to
read one input byte and return true if byte is non zero, false if byte is
zero.
|
int
skipBytes(int x)
|
It is used to
skip over x bytes of data from the input stream.
|
String readUTF()
|
It is used to
read a string that has been encoded using the UTF-8 format.
|
void
readFully(byte[] b)
|
It is used to
read bytes from the input stream and store them into the buffer array.
|
void
readFully(byte[] b, int off, int len)
|
It is used to
read len bytes from
the input stream.
|
Method
|
Description
|
int size()
|
It is used to
return the number of bytes written to the data output stream.
|
void write(int
b)
|
It is used to
write the specified byte to the underlying output stream.
|
void write(byte[]
b, int off, int len)
|
It is used to
write len bytes of data to the output stream.
|
void
writeBoolean(boolean v)
|
It is used to
write Boolean to the output stream as a 1-byte value.
|
void
writeChar(int v)
|
It is used to
write char to the output stream as a 2-byte value.
|
void
writeChars(String s)
|
It is used to
write string to the output stream as a sequence of characters.
|
void
writeByte(int v)
|
It is used to
write a byte to the output stream as a 1-byte value.
|
void
writeBytes(String s)
|
It is used to
write string to the output stream as a sequence of bytes.
|
void
writeInt(int v)
|
It is used to
write an int to the output stream
|
void
writeShort(int v)
|
It is used to
write a short to the output stream.
|
void
writeShort(int v)
|
It is used to write
a short to the output stream.
|
No comments:
Post a Comment