?? chap8-3.txt
字號:
// 程序8-3
import java.io.*;
class fileWriteInfo {
void writeInfo( )throws IOException{
int size=0;
byte b[ ]=new byte[6]; // 創建一個文件輸出對象
FileOutputStream fout=new FileOutputStream("d:/abc.txt");
try{
System.out.print("Enter 6 chars: ");
for(int i=0;i<6;i++) // 從鍵盤讀6個字節
b[i]=(byte)System.in.read( );
fout.write(b); // 將數組的內容一次寫到文件
}catch(IOException e){
System.out.print("file IOException!");
}finally{
fout.close( ); // 關閉文件
}
}
}
public class fileWriteTest {
public static void main(String args[ ]) {
fileWriteInfo obj=new fileWriteInfo ( );
try{
obj.writeInfo( );
}catch(IOException e) {
System.out.println("File not found : "+e);
e.printStackTrace( );
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -