import java.io.*;public class iotest{
public static void main(String args[]){
FileOutputStream f = null;
int c = 0;
    f = new FileOutputStream("D:/java/马士兵/iotest.java");
System.out.println("显示");
while((c = f.read()) != -1){
System.out.println(c);
}
f.close();
}
}

解决方案 »

  1.   

    public class iotest{
    public static void main(String args[]) throws IOException{
    FileInputStream f = null;
    int c = 0;
      f = new FileInputStream("D:/java/马士兵/iotest.java");
    System.out.println("显示");
    while((c = f.read()) != -1){
    System.out.println(c);
    }
    f.close();
    }
    }
      

  2.   


    public void printFile(String fileName){
    StringBuffer buffer = new StringBuffer();
    try {
    BufferedReader reader = new BufferedReader(new FileReader(fileName));
    while(reader.ready()){
    buffer.append(reader.readLine());
    }
    System.out.println("输出文件内容的结果为:" + buffer.toString());
    reader.close();
    } catch (Exception e) {
    e.printStackTrace();
    }
    }是什么问题还没有说明呀!
      

  3.   


    public static void main(String args[]) throws Exception{
    FileInputStream f = null;
    int c = 0;
    f = new FileInputStream("D:\\workspace\\cloudserver\\src\\TreeMenu.txt");
    System.out.println("显示");
    byte[] ch = new byte[1024];
    while ((c = f.read(ch)) != -1) {
    System.out.println(new String(ch, 0, c));
    }
    f.close();
    }这样修改就可以了
      

  4.   

    我也想问 为什么输出流会有read呢?