코드 예제

String filepath = "C:\\Users\\402-08\\Desktop\\jp\\Penguins.jpg";

// \\을 기준으로 데이터를 나누어 ar에 데이터를 넣어준다.
String[] ar = filepath.split("\\\\");

// 데이터의 길이를 length로 확인하여 -1을 해주면 마지막 데이터를 가져올 수 있다.
String file = ar[ar.length - 1];

+ Recent posts