파일 경로에서 마지막 폴더 이름을 추출하는 방법
Java로 파일 다루는 코드를 짜다보면 서비스별로 폴더명을 다르게 설정하고 이용하고 그런경우가 자주 있습니다. 다음은, 파일을 가져오는 폴더명에서 서비스를 구별하고 싶을때, 마지막 폴더명을 가져오는 예제입니다. import java.nio.file.Path; import java.nio.file.Paths; public class Main { public static void main(String[] args) { String filePath = "C:/Users/ExampleUser/Documents/ExampleFolder"; Path path = Paths.get(filePath); Path folderName = path.getFileName(); System.out.println("마지막 폴더 ..