package Lec11;
import java.io.*;
import java.util.*;
class FileInfor03 { //課題で変更
FileInfor03
(String fileName
) { File f
= new File(fileName
); // 指定されたファイル情報を取得する System.
out.
println("exists() :" + f.
exists()); // 存在するか? System.
out.
println("getName() :" + f.
getName()); // 名前 System.
out.
println("canRead() :" + f.
canRead()); // 読めるか? System.
out.
println("canWrite() :" + f.
canWrite()); // 書けるか? System.
out.
println("getAbsolutePath():" + f.
getAbsolutePath()); // 絶対パス System.
out.
println("getPath() :" + f.
getPath()); // パス System.
out.
println("isAbsolute() :" + f.
isAbsolute()); // 絶対パス名か? System.
out.
println("isDirectory() :" + f.
isDirectory()); // フォルダか? System.
out.
println("isFile() :" + f.
isFile()); // ファイルか? System.
out.
println("isHidden() :" + f.
isHidden()); // 隠しファイルか? System.
out.
println("lastModified() :" + f.
lastModified()); // 最終更新日:long型 System.
out.
println("length() :" + f.
length()); // 大きさ
System.
out.
println(DateToString
(new Date(f.
lastModified()))); //課題で変更
}
public static void main
(String[] args
) { String fileName
= "C:/CSExBecripse/src/Lec11/test1.txt"; FileInfor03 fileInfo = new FileInfor03(fileName); //課題で変更
}
//課題で追加
//Calendarクラスは抽象クラスなのでインスタンス生成をgetInstanceというクラスメソッドで行う
//このCalendarをlastDateで指定された日時に設定する
cal.setTime(dt);
sDate
[1] = String.
valueOf(cal.
get(Calendar.
MONTH) + 1) + "月"; //正しい月が表示されるように変更。 for (int i = 0; i < 7; i++) {
strDate = strDate + sDate[i];
}
return strDate;
}
}
cGFja2FnZSBMZWMxMTsKCmltcG9ydCBqYXZhLmlvLio7CmltcG9ydCBqYXZhLnV0aWwuKjsKCmNsYXNzIEZpbGVJbmZvcjAzIHsgLy/oqrLpoYzjgaflpInmm7QKCiAgICBGaWxlSW5mb3IwMyhTdHJpbmcgZmlsZU5hbWUpIHsKICAgICAgICBGaWxlIGYgPSBuZXcgRmlsZShmaWxlTmFtZSk7IC8vIOaMh+WumuOBleOCjOOBn+ODleOCoeOCpOODq+aDheWgseOCkuWPlu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