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);
}
}
arrow
arrow
    全站熱搜

    Neo Chao 發表在 痞客邦 留言(0) 人氣()