fileinputexample.java

来自「Java课堂练习」· Java 代码 · 共 41 行

JAVA
41
字号
/**
 * @(#)FileInputExample.java
 *
 *
 * @author 
 * @version 1.00 2007/11/25
 */
import  java.io.*;

public class FileInputExample {
        
    /**
     * Creates a new instance of <code>FileInputExample</code>.
     */
    public FileInputExample() {
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
      byte  fileContent[]=new byte[20];
      int b;
      try {
       File f=new File("ButtonLabelExp.java");
       FileInputStream in=new FileInputStream(f);
       while ((b=in.read(fileContent,0,20))!=-1)  {
       	String s=new String(fileContent,0,b);
       	System.out.println(s);
       }
       in.close();
      }
      catch (IOException e) {
      	System.out.println("error occured in file read!"+e);
      }
    }

    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?