Java常用类总结

ava.io-------包

接口:--------两个顶级接口

DataInput----接口

Public interface DataInput

方法:

Boolean readBoolean()----读取一个字节,!0---true,0----false

Byte readByte()------1

Int readInt()-------4

Char readChar()------2

Double readDouble()------8

Float readFloat()----4

String readLine()-----一行文本

Long readLong()------8

Short readShort()------2

DataOutput-----接口

Public interface DataOutput

方法:

Void write(byte[] b)-------将b中的所有字节写入输出流中

Void write(byte[] b, int off, int len)

Void write(int i)------将参数b的八个低位写入输出流

Void writeBoolean(boolean b)

Void writeInt(int i)

Void writeChar(char c)

Void writeShort(short s)

Void writeDouble(double b)

Void writeLong(long l)

Void writeFloat(float f)

常用类:

/*Java教程:http://www.javaweb.cc*/

InputStream------类

Public abstract class InputStream extends Object

构造方法:InputStream()

普通方法:

Void close(),关闭流

Abstract int read()从输入流中的数据中读取下一个字节

Int read(byte[] b)从输入流中读取一定数量的字节,并且将其存入b数组中,返回值是实际读取的字节数

Int read(byte[] b,int off,int len)

OutputStream--------类

Public abstract class OutputStream extends Object

Void close()

Void Flush();刷新此输出流,并且强制写出所有缓冲的输出字节

Void Write(byte[] b);将数组长度的字节从指定的数组写入输出流

Void write(int t);-----是个抽象的方法,将指定的字节写入此输出流

Void wirte(byte[] b,int off,int len)

Reader------类

Public abstract class Reader extends Object

构造方法:

Reader()

普通方法:

Close()

Int read();读取单个字符,

Int read(char c);将字符读入数组,

Int read(char[] c int off , int len)-----

Writer--------类

Public abstract class Writer extends Object

构造方法:

Writer()

普通方法:

Close()

Wirter append(char c)----将指定的字符追加到此writer上

Flush()

Writer(char c)-----写入字符数组到这个输出流中

Writer(char c,int off,int len)------写入数组中的一部分

Writer(int i)-----写入单个字符

Writer(String s)-----写入字符串

Writer(String s,int off, int len)-----写入字符串的一部分

FileInputStream--------类

Public class FileInputStream extends InputStream

构造方法:

FileInputStream(File file)-----新创文件

FileInputStream(String name)------文件的路径

普通方法:

Void close()

Int read()-----从输入流中读取一个字节

Int read(byte[] b)-----从输入流中读取最多b.length,长度的字节到数组byte[]中

Int read(byte[] b,int off,int len)

FileOutputStream-------类

Public class FileOutputStream extends OutputStream

构造方法:

FileOutputStream(File file)

FileOutputStream(String name)

普通方法:

Void colse()

Void write(byte[] b)--从指定的数组b中往输出流中写入b.length长度的数据

Void write(byte[] b, int off, int len)-----

Void write(int n)将指定字节输入此输出流中

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章