FilenameUtilsのサンプル

コード

File file = new File("C:\\sample\\test\\文章.txt");
1:file.getPath());
2:FilenameUtils.getBaseName(file.getPath()));
3:FilenameUtils.getName(file.getPath()));
4:FilenameUtils.getPath(file.getPath()));
5:FilenameUtils.getPathNoEndSeparator(file.getPath()));
6:FilenameUtils.getFullPath(file.getPath()));
7:FilenameUtils.getFullPathNoEndSeparator(file.getPath()));
8:FilenameUtils.getPrefix(file.getPath()));
9:FilenameUtils.getPrefixLength(file.getPath()));
10:FilenameUtils.getExtension(file.getPath()));


実行結果

1:データ =C:\sample\test\文章.txt
2:getBaseName =文章
3:getName =文章.txt
4:getPath =sample\test\
5:getPathNoEndSeparator =sample\test
6:getFullPath =C:\sample\test\
7:getFullPathNoEndSeparator =C:\sample\test
8:getPrefix =C:\
9:getPrefixLength =3
10:getExtension =txt