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();
}
}
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();
}
}
解决方案 »
- InputStream的public int read(byte[] b)里byte的取值范围为-128~127 读取的字节的范围应该是0~255吧,byte数组不会越界么?谢谢!
- Java怎样从TXT中一个一个读取字符串?
- 有关lastModified()的一个问题
- Show过时了~用什么代替呢~?
- javaBean的 问题?高手过来看下
- 高分请教.JAVA的IO问题?
- 为什么double类型的变量除零不会产生异常
- 急问对正确与否时间的判断,在线等~~~~
- 各位网友:请帮我指点方向
- 哪位大虾有jrun3.0的序列号,救命呀!
- 求为JTextField添加Auto Completion功能的代码
- 这个场景用什么集合对象呢?
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();
}
}
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();
}
}是什么问题还没有说明呀!
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();
}这样修改就可以了