How to handle forward slash in file path. My requirement is to read the contents of a csv file. But giving something like
String fileName = "MyNewFile.csv"
is converting /
to \
.
My operating system is Windows. I am using RAD IDE.
Using File.Separator
didn't help. Giving me a The system cannot find the path specified.
error.
Tried this:
InputStream is = SampleClass.class.getClassLoader().getResourceAsStream("MyNewFile.csv");
BufferedReader br = new BufferedReader(new InputStreamReader(is));
And this:
The moment I try to escape /
as \/
IDE shows me a compilation error Invalid escape sequence (valid ones are \b \t \n \f \r \" \' \\ )
Tried moving the file directly under the project(moved it out from src folder) and changed the code as br = new BufferedReader(new FileReader(csvFile));
But still seeing The system cannot find the file specified.
error
Can anyone please help ???