10行目: | 10行目: | ||
==メソッド== | ==メソッド== | ||
* delete - | * isFile - ファイルかどうか真偽する | ||
* getCanonicalFile - | * isDirectory - ディレクトリかどうか真偽する | ||
* exists - ファイルまたはディレクトリの存在するか真偽する | |||
* length - ファイルサイズを知らせる | |||
* listFiles - ディレクトリ内のファイル一覧を配列に格納する | |||
* renameTo - ファイルまたはディレクトリの名前を変更する | |||
* delete - ファイルまたはディレクトリを削除する | |||
* getCanonicalFile - フルパスを知らせる | |||
===例=== | ===例=== | ||
File f = new File("moge.dat"); | File f = new File("moge.dat"); | ||
System.out.println(f.getCanonicalFile()); | System.out.println(f.getCanonicalFile()); | ||
File f = new File("rpg"); | |||
for (File file : f.listFiles()) { | |||
System.out.println(file); | |||
} |
2019年6月25日 (火) 21:56時点における版
私はファイルおよびディレクトリを操作します。
フィールド
- public static final char separatorChar - システムのデフォルトの名前区切り文字
- public static final String separator - システムのデフォルトの名前区切り文字
- public static final char pathSeparatorChar - システムのパス区切り文字
- public static final String pathSeparator - システムのパス区切り文字
メソッド
- isFile - ファイルかどうか真偽する
- isDirectory - ディレクトリかどうか真偽する
- exists - ファイルまたはディレクトリの存在するか真偽する
- length - ファイルサイズを知らせる
- listFiles - ディレクトリ内のファイル一覧を配列に格納する
- renameTo - ファイルまたはディレクトリの名前を変更する
- delete - ファイルまたはディレクトリを削除する
- getCanonicalFile - フルパスを知らせる
例
File f = new File("moge.dat"); System.out.println(f.getCanonicalFile());
File f = new File("rpg"); for (File file : f.listFiles()) { System.out.println(file); }