Click here to Skip to main content
15,616,639 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,

I know that "\" is an escape character, but is there really no possibility to read it as a "normal" character?

I wanted to read a path (which is read out in a string) character by character and check whether one is a backslash.. but that only works if i put double backslashes in the path.

Hope you can help me!

String slash = "\\";

There's no alternatives.
Share this answer
epanjohura 10-Oct-11 2:20am    
that also doesn't work, but I think I found the problem :)
André Kraak 10-Oct-11 2:33am    
If you have found the solution please post it as a solution here, so that anyone with a similar problem can use it.
Thank you.
epanjohura 10-Oct-11 2:34am    
yes of course I'll post it here, I'm just trying if this works :)
epanjohura 12-Oct-11 1:42am    
I found a solution ;)
My Solution:

First I used
import java.util.Properties;
import java io.IOException;

and loaded the file with
private static String InFile;
String Path;

Properties props = new Properties();
FileInputStream in = null;

// create input stream to read file
    in = new FileInputStream(new File(Path));
} catch(FileNotFoundException e1) {

} catch(IOException e) {

I got my path by searching in file by a key word p.E.
InFile = props.getProperty("Path=");

and thats not a good idea for that what I did.
As I said, I wanted to check if there is any backslash in the path, if yes then add another backslash.
Well, that's what I did instead of using this properies:
import java.util.Scanner;

String Lines = null;

FileReader fr = new FileReader(Path);
Scanner input = new Scanner(fr);

// read out each line of file
    Lines = input.nextLine();

I hope everyone understand what I'm trying to explain :)

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900