import java.io.*;public class CountBytes {
public static void main(String[]args) throws IOException{
InputStream in;
//get the file name
if(args.length==0)
in=System.in;
else
in=new FileInputStream(args[0]);
//count the byte of file
int total=0;
while(in.read()!=-1)
total++;
System.out.println(total+"bytes");
}
}这个程序在eclipse运行后,我在Console里敲进文件名,enter后没反应的eclipse里的console窗口是不是只用于输出的,要读取键盘输入怎么办,可不可以调用dos的?
public static void main(String[]args) throws IOException{
InputStream in;
//get the file name
if(args.length==0)
in=System.in;
else
in=new FileInputStream(args[0]);
//count the byte of file
int total=0;
while(in.read()!=-1)
total++;
System.out.println(total+"bytes");
}
}这个程序在eclipse运行后,我在Console里敲进文件名,enter后没反应的eclipse里的console窗口是不是只用于输出的,要读取键盘输入怎么办,可不可以调用dos的?
解决方案 »
- string[]中查找问题
- 如何执行完一句语句后停止100ms
- 复制文件好慢,谁帮我改改程序?
- JTextArea类的方法
- 网页插入applet,安装控制台?
- 解析XML错误:Invalid encoding name "GBK".???
- 不行啊!?为什么老说有错!
- JBuilder5开发RMI程序,为什么没有VisiBroker Library?
- 怎样才能提高JAVA方面的水平
- 要让一个.jar能双击运行,必须要有jre,是不是除了xp之外的其他windows都自带有jre阿?linux呢?
- 很郁闷啊java竟然找不到把jpg 转 成dicom格式的方法
- comparable和Comparator区别,怎么用?望高手指教.
//count the byte of file
int total=0,n=-1;
while((n=in.read())!=-1)
total++;
System.out.println(total+"bytes");