java I/O系统总结
1、 InputStream : 從文件、網絡、壓縮包等中讀取 需要的信息到程序中的變量
read(); ? ? read(byte []b );
mark(int readlimit);
reset(); ?將輸入指針返回到當前所做的標記處
skip(long n); ?close();
子類: ?FileInputStream
FilterInputStream——BufferInputStream,DataInputStream.....(FIleInputStream的子類)
StringBufferInputStream
2、 OutputStream : ?將內存中的信息 輸出到 文件、網絡、壓縮包中
write(int n); //指定的字節寫入到輸出流
write(byte[] b) ; write(byte[]b,int off,int len);
flush(); ?//徹底完成輸出,并清空緩沖區
close();
?
3、 File 類
構造方法: ?File(String PathName); ?//可以是一個路徑,也可以是一個路徑+文件?
File(String fater,String child);
File(File f,String child);
成員: ?createNewFile();
.delete(); .getName(); .canRead();canWrtie();exists();length();
.getAbsolutePath(); isFile(); isDirectory();......
?
4、文件輸入輸出流
FileInputStream、FileOutputStream 以字節流的形式輸入輸出
new FileInputStream(File f);
new FileInputStream(String name); // 通過給定的文件名創建FileInputStram對象
read(byte []b) ; 將FIle中的信息讀取到 byte數組中
同樣:FIleOutStream();
write(byte []b); 將信息寫入到文件中
byte[] b = "hello world".getBytes(gbk); //得到
如果不指定編碼格式,得到系統自帶的編碼格式。可以指定: gbk utf-8 iso-8859-1
String s_gbk = new String(b, "gbk"); // 與上述過程相反
?
?FileReader 和 FileWriter (以字符流的形式輸出)
.read(char []c); ?.write(String s);
?
5、 帶緩存的輸入輸出流
?
?
轉載于:https://www.cnblogs.com/NeilZhang/p/6829717.html
總結
以上是生活随笔為你收集整理的java I/O系统总结的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Haoop基本操作
- 下一篇: rem和em学习笔记及CSS预处理