⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chap8-3.txt

📁 JAVA 学习资源
💻 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 + -