Java Path-String에서 사용 File.separator과 일반 의 차이점은 무엇입니까 /?
이중 백 슬래시 \\플랫폼 독립성 과 달리 두 버전 모두 Windows 및 Unix에서 작동하기 때문에 이유가 아닌 것 같습니다.
public class SlashTest {
@Test
public void slash() throws Exception {
File file = new File("src/trials/SlashTest.java");
assertThat(file.exists(), is(true));
}
@Test
public void separator() throws Exception {
File file = new File("src" + File.separator + "trials" + File.separator + "SlashTest.java");
assertThat(file.exists(), is(true));
}
}
/유닉스와 윈도우에서 작동 한다면 , 왜 그 질문을 바꾸어 놓아야 File.separator합니까?