谁能帮我编个JAVA程序?
来源:百度知道 编辑:UC知道 时间:2024/05/14 12:36:05
address.txt:1025
report.txt:447
好的给高分,谢谢各位大大了!
public class WordCount {
public WordCount() {
new Thread(new WordCountThread()).start();
}
public static void main(String[] args) {
new WordCount();
}
}
public class WordCountThread implements Runnable {
private String path;
public void run() {
Scanner sc = new Scanner(System.in);
System.out.print("请输入文件的路径:");
path = sc.nextLine();
if(path != null)
{
String fpath = path.replace("\\", "\\\\");
File f = new File(fpath);
if(f.exists())
{
try {
//FileInputStream in = new FileInputStream(f);
InputStream i = new FileInputStream(f);
System.out.println(f.getName() +" : "+ i.available());
// BufferedInputStream br = new BufferedInputStream(i);
//DataInputStream d = new DataInputStream(i);
} catch (FileNot