天天看點

java擷取路徑和檔案名

public static void main(String[] args) {
        String errInfoPath="/app/home/S_I_000000000001.zip";
        String errorZipFileName = errInfoPath.substring(errInfoPath.lastIndexOf("/") + 1);
        String errorZipFilePath = errInfoPath.substring(0, errInfoPath.lastIndexOf("/") + 1);
        System.out.println("處理後的檔案名:"+errorZipFileName);
        System.out.println("處理後的檔案目錄:"+errorZipFilePath);
    }