Java Path-String'de kullanma File.separatorve normal /arasındaki fark nedir ?
İki ters eğik çizgi \\platformunun aksine , her iki sürüm de Windows ve Unix altında çalıştığı için bağımsızlık nedeni görünmüyor.
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));
}
}
Soruyu yeniden ifade etmek için /, Unix ve Windows üzerinde çalışıyorsa neden kullanmak istesin ki File.separator?