File.getAbsolutePath()でファイルパスを取得するサンプル
サンプルコード
package com.demopro;
import java.io.File;
public class AbsolutionPathDemo {
public static void main(String[] args) {
String filePath = "D:\\test\\cft\\kdf.csv";
File file = new File(filePath);
System.out.println("親のパス名:" + file.getParent());
System.out.println("パス名:" + file.getPath());
System.out.println("絶対パス名:" + file.getAbsolutePath());
}
}
結果
親のパス名:D:\test\cft
パス名:D:\test\cft\kdf.csv
絶対パス名:D:\test\cft\kdf.csv