文件输入流
public class InputStreamTest { public static void main(String[] args) { InputStream fis=null; try{ //2.创建文件输入对象 fis=new FileInputStream("D:\\doc\\test.txt"); System.out.println("可读取的字节数: "+fis.available()); //3.执行读操作 int data=0; //循环读取数据 System.out.println("文件的内容: "); while((data=fis.read())!=-1){ System.out.print((char)data+" "); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally { try{ if (fis!=null){ fis.close(); } } catch (IOException e) { e.printStackTrace(); } } } }