import java.awt.*;
import java.io.File;
import java.util.HashMap;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.filechooser.*;
import javax.swing.event.*;

public class FileTest
{
public static void main(String args[])
{
//önce JFileChooser kullanarak dosyayı seç, sonra dosya özelliklerini göster.
File f=new File("readfromfile1.java");
JFileChooser dosyasec=new JFileChooser();
int approval = dosyasec.showOpenDialog(null);
if(approval==JFileChooser.APPROVE_OPTION)
{
f=dosyasec.getSelectedFile();
}
String s="";
s+="File name : "+f.getName()+"\n";
s+="Directory name : "+f.getPath()+"\n";
s+="Absolute directory name : "+f.getAbsolutePath()+"\n";
s+="Parent directory name : "+f.getParent()+"\n";
s+=f.exists() ? "Existed " : " Not existed "+"\n";
s+=f.canWrite() ? "Writable " : " Not writable"+"\n";
s+=f.canRead() ? "Readable " : " Not Readable"+"\n";
s+=f.isDirectory() ? "Directory " : " Not directory"+"\n";
s+=f.isFile() ? "File " : " Not File"+"\n";
s+=f.isAbsolute() ? "Absolute file name " : " not an absolute file name"+"\n";
s+="Last modified : "+f.lastModified()+"\n";
s+="File size : "+f.length()+" Byte"+"\n";
JOptionPane.showMessageDialog(null,s,"File test",JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
}
