Backslash, File directories, and streams
I dont really know where i should post this, so im just posting it here.
I have a program, and part of it is to read a file, find a string, modify the string, and write it back to the file. The string in question is a file directory on windows, so it has backslashes (\).
The originial string from the file:
"string filename" ["C:\\My\\Fike\\Path\\toChange\\ta-00042"]
I read the string using
And read all the lines of the code, split it using
FileInputStream fis = new FileInputStream((test));
BufferedReader is = new BufferedReader(new InputStreamReader(fis));
I need to change the String with a new filepath, and written out with 2 backslashes, like the originial. I make a new string, and use a string containing the directory. The directory was taken from a JTextField, so only 1 slash.
String lines = file.split("\n");
How can i replace all these '\' with '\\'? Do i need to add more to have the FileWriter print the correct amount of literals?
When the FileInputStream reads the file, does it do anything to the backslashes?
I have tried
but i am getting the same output as input with System.out.println();