-3
문자열 imgpath = "/ mnt/sdcard/joke.png";
출력 :. "을/mnt/sdcard에내 응용 프로그램에서 전체 이미지 경로를 얻고 있습니다. 나는 오직 길을 얻고 싶다
문자열 imgpath = "/ mnt/sdcard/joke.png";
출력 :. "을/mnt/sdcard에내 응용 프로그램에서 전체 이미지 경로를 얻고 있습니다. 나는 오직 길을 얻고 싶다
몇 가지 옵션이 있습니다 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
나는 후자를 선호
으로 당하지만, 그것은 당신에게 달렸습니다.
질문을 올바르게 설명하십시오 .... –
그래서 기본적으로 파일 이름을 제거하고 싶습니다. –