导图社区 java中io流图解
计算机专业小伙伴必学的干货知识! java中常用的io流相有什么?作者以自己多年的编程经验和结合课本知识,为大家总结java中常用的io流图解,如果对你有帮助的话不妨动动小手指对作者点个赞呀! |
编辑于2018-11-08 09:24:03io流
字节流
InputStream
FileInputStream
概要
构造器
public FileInputStream(String name){}
public FileInputStream(File file){}
FilterInputStream
BufferedInputStream
概要
构造器
public BufferedInputStream(InputStream in){}
public BufferedInputStream(InputStream in, int size){}
成员变量
protected volatile byte buf[];
DataInputStream
概要
构造器
public DataInputStream(InputStream in){}
方法
readInt()、readShort().....
ByteArrayInputStream
概要
构造器
public ByteArrayInputStream(byte buf[]){}
public ByteArrayInputStream(byte buf[], int offset, int length){}
成员变量
protected byte buf[];
SequenceInputStream
概要
构造器
public SequenceInputStream(Enumeration<? extends InputStream> e){}
public SequenceInputStream(InputStream s1, InputStream s2){}
成员变量
Enumeration<? extends InputStream> e;
InputStream in;
ObjectInputStream
概要
构造器
public ObjectInputStream(InputStream in){}
方法
public final Object readObject(){}
OutputStream
FileOutputStream
概要
构造器
public FileOutputStream(String name){}
public FileOutputStream(String name, boolean append){}
public FileOutputStream(File file){}
public FileOutputStream(File file, boolean append){}
FilterOutputStream
BufferedOutputStream
概要
构造器
public BufferedOutputStream(OutputStream out){}
public BufferedOutputStream(OutputStream out, int size){}
成员变量
protected byte buf[];
DataOutputStream
概要
构造器
public DataOutputStream(OutputStream out){}
方法
writeInt().....
PrintStream
字节打印流,标准输出流的对象
概要
构造器
public PrintStream(OutputStream out){}
public PrintStream(OutputStream out, boolean autoFlush){}
public PrintStream(OutputStream out, boolean autoFlush, String encoding){}
public PrintStream(String fileName){this(false, new FileOutputStream(fileName));}
public PrintStream(File file){}
public PrintStream(File file, String csn){}
成员变量
private OutputStreamWriter charOut;
private BufferedWriter text
方法
print()
println()
ByteArrayOutputStream
概要
构造器
public ByteArrayOutputStream(){}
public ByteArrayOutputStream(int size){}
成员变量
protected byte buf[];
方法
public synchronized byte toByteArray()[] {return Arrays.copyOf(buf, count);}
ObjectOutputStream
概要
构造器
public ObjectOutputStream(OutputStream out) {}
方法
public final void writeObject(Object obj){}
字符流
Reader
InputStreamReader
概要
构造器
public InputStreamReader(InputStream in){}
public InputStreamReader(InputStream in, String charsetName){}
public InputStreamReader(InputStream in, Charset cs) {}
方法
public String getEncoding(){}
子类
FileReader
概要
构造器
super(new FileInputStream(...));
public FileReader(String fileName){}
public FileReader(File file){}
BufferedReader
概要
构造器
public BufferedReader(Reader in, int sz) {}
public BufferedReader(Reader in){}
方法
public String readLine(){}
成员变量
private Reader in;
private char cb[];
CharArrayReader
概要
构造器
public CharArrayReader(char buf[]){}
public CharArrayReader(char buf[], int offset, int length){}
成员变量
protected char buf[];
StringReader
概要
构造器
public StringReader(String s){}
成员变量
private String str;
Writer
OutputStreamWriter
概要
构造器
public OutputStreamWriter(OutputStream out, String charsetName){}
public OutputStreamWriter(OutputStream out) {}
public OutputStreamWriter(OutputStream out, Charset cs) {}
public FileOutputStream(File file, boolean append){}
方法
public String getEncoding(){}
子类
FileWriter
概要
构造器
super(new FileOutputStream(...))
public FileWriter(String fileName){}
public FileWriter(String fileName, boolean append){}
public FileWriter(File file) {}
public FileWriter(File file, boolean append){}
BufferedWriter
概要
构造器
public BufferedWriter(Writer out){}
public BufferedWriter(Writer out, int sz){}
子主题
方法
public void newLine(){}
成员变量
private Writer out;
private char cb[];
CharArrayWriter
概要
构造器
public CharArrayWriter(){}
public CharArrayWriter(int initialSize){}
成员变量
protected char buf[];
方法
public char toCharArray()[] {synchronized (lock) {return Arrays.copyOf(buf, count);}}
StringWriter
概要
构造器
public StringWriter() {buf = new StringBuffer();lock = buf;}
public StringWriter(int initialSize){}
成员变量
private StringBuffer buf;
方法
public StringBuffer getBuffer(){}
PrintWriter
字符打印流
概要
构造器
public PrintWriter (Writer out){}
public PrintWriter(OutputStream out){}
public PrintWriter(String fileName){}
public PrintWriter(File file){}
成员变量
protected Writer out;
方法
print()
println()
标准输入输出流
System.in
通常作为Scanner的对象
System.out
实则调用的是PrintStream的功能。为什么在控制台输出呢?是因为PrintStream printStream = new PrintStream(new FileOutputStream(FileDescriptor.out));