2011-08-30 9 views

답변

5

테스트되었고 임의의 수의 슬래시가 대체됩니다.

String path = yourString.replaceFirst("file:/*", ""); 

그리고 당신은 단지 그것을 두 개 또는 세 개의 슬래시

String path = yourString.replaceFirst("file:/{2,3}", ""); 
+0

두 번째 해결 방법은 매우 –

+0

+1입니다. :) – user802421

+0

'[]'는 중복됩니다. 또한'///?'는'/ {2,3}'보다 짧고 간단합니다. –

0

당신이 문자열 "파일 : //"대체 할 수있는 문자열에 아무것도 : 그것에 대해

String path = yourString.replace("file://", ""); 
+0

그리고 그것은 무엇'파일을 추천 슬래시가 포함 된 경우 일치 할 경우 : ///'를? –

+0

위의 대답은 file : /// f :/temp/.... file : /// H :/something/....을 만족하지 않습니다. – developer

+0

'String path = yourString.replaceFirst ("^ file : // /? "," ");'- String.replace (String, String)'메소드가 없습니다. –

0

무엇을?

String path = yourString.replaceFirst("file:[/]*", ""); 
+0

'[]'는 중복됩니다. –

1
String path = new java.net.URI(fileUrl).getPath(); 
관련 문제