java第十章总结
文件執(zhí)行
Runtime ec = Runtime.getRuntime();
ec.exec(String command);
文件字節(jié)輸入流
try{
FileInputStream in = new FileInputStream("hello.txt");}
catch(IOException e){}
int read();int read(byte b[]);int read(byte b[],int off,int len);
輸出
File f=new File("abc.txt");
FileOutputStream out=new FileOutputStream (f);
void write(int b);void write(byte[] array);void write(byte[] array, int offset, int length); void close();
文件字符輸入輸出流
FileReader FileWriter
緩沖流
BufferedReader? ? ? 讀取一行 readLine();
數(shù)據(jù)流?
DataInputStream
public?String readUTF(); 讀入一個(gè)已使用UTF-8修改版格式編碼的字符串
public?String readLine();
public?boolean?readBoolean;
public?int?readInt();
public?byte readByte();
public char readChar(); 等等一系列讀取基本數(shù)據(jù)類型的方法
如果發(fā)生I/O類型錯(cuò)誤,會(huì)拋出IOException類型的異常。
DataOutputStream
? ? public?void writeBoolean(boolean b); 將一個(gè)boolean值以1-byte形式寫入基本輸出流。
public?void writeByte(int v); 將一個(gè)byte值以1-byte值形式寫入到基本輸出流中。
public?void writeBytes(String s); 將字符串按字節(jié)順序?qū)懭氲交据敵隽髦小?/p>
public?void writeChar(int v); 將一個(gè)char值以2-byte形式寫入到基本輸出流中。先寫入高字節(jié)。
public?void writeInt(int v); 將一個(gè)int值以4-byte值形式寫入到輸出流中先寫高字節(jié)。
public?void writeUTF(String str);
public?int size(); 返回written的當(dāng)前值。
如果發(fā)生I/O類型錯(cuò)誤,會(huì)拋出IOException類型的異常。
總結(jié)
 
                            
                        - 上一篇: C语言数组应用
- 下一篇: 即时通讯开发(逐行、隔行扫描)
