close
import java.io.*;
import javax.swing.*;
class ReaderFile02
{
public static void main(String[] args)
{
try
{
String fpath = JOptionPane.showInputDialog("請輸入檔案路徑");
File f = new File(fpath);
FileReader fin=new FileReader(f);
int size = (int)f.length();
String name = f.getName();
char buffer[] = new char[size];
System.out.println("檔案名稱: " + name);
System.out.println("檔案總長度: " + size);
fin.read(buffer);
System.out.println(buffer);
fin.close();
}
catch (IOException e)
{
JOptionPane.showMessageDialog(null,"輸入檔案路徑有誤!!");
}
catch (Exception e)
{}
System.exit(0);
}
}
全站熱搜