2016-10-25 1 views

답변

1

몇 가지 옵션이 있습니다 https://www.mkyong.com/java/how-to-get-the-filepath-of-a-file-in-java/

String imgpath ="/mnt/sdcard/joke.png"; 
String path = imgpath . substring(0, imgpath.lastIndexOf(File.separator)); 

또는 사용이

String imgpath ="/mnt/sdcard/joke.png"; 
String path = new File(imgpath).getParent(); 

java.io.File 나는 후자를 선호

으로 당하지만, 그것은 당신에게 달렸습니다.

관련 문제