2

I'm trying to input backslash in my java file through Eclipse IDE.

When using File.separator, the return is \, so my program returns an error indicating that it cannot locate the file because of the path returned like this:

¥¥¥¥C:¥¥Users¥¥Test Folder\xls\Test.xls

Here's my pseudo-code:

String path = ¥¥¥¥C:¥¥Users¥¥Test Folder;
String pathToConcat = File.separator + "xls" + File.separator + "Test.xls";

I tried pressing the backslash in notepad and it returns \, but in eclipse, it is ¥.

gengencera
  • 426
  • 2
  • 15
  • Have you tried copying and pasting it in from notepad in your string variable – Krishnanshu Gupta May 10 '18 at 01:34
  • The path returned? If it is copy paste from debugger to notepad I get ¥¥¥¥C:¥¥Users¥¥¥¥Test Folder\xls\Test.xls And if I copy paste \\\\C:\\Users\\Test Folder from notepad to java file in Eclipse. It returns ¥¥¥¥C:¥¥Users¥¥Test Folder – gengencera May 10 '18 at 01:35
  • 1
    Can you see if this link to a similar problem helps you: https://superuser.com/questions/1167662/why-is-windows-10-displaying-as-%C2%A5-on-the-command-line/1167665 – Krishnanshu Gupta May 10 '18 at 01:37
  • @KrishnanshuGupta The solution offered in the link above is applied to my pc currently. I ensured that my default language for non-unicode is English US – gengencera May 10 '18 at 01:39
  • 2
    I'll try to look something up to hopefully help you. – Krishnanshu Gupta May 10 '18 at 01:45
  • Set the global text file encoding preference Workbench > Editors to "UTF-8". according to this link https://stackoverflow.com/questions/200691/how-to-use-special-chars-in-java-eclipse – Angel Koh May 10 '18 at 01:48
  • @KrishnanshuGupta Thanks! I now tried setting my language, region to Japanese and the program has no errors, it works, I have no issue in the path returned (¥¥¥¥C:¥¥Users¥¥Test Folder¥¥xls¥¥Test.xls). However changing it back to US, it is still the issue. – gengencera May 10 '18 at 01:52
  • @gengencera, can you try typing alt 9 2, and then release alt key. This will only work on windows I believe. But the numbers have to be on the key/num pad thing – Krishnanshu Gupta May 10 '18 at 03:58
  • For an explanation, in windows you can press alt and then ascii code to get the specified character – Krishnanshu Gupta May 10 '18 at 03:59
  • That's as much as I can find on the internet, hope something I mentioned helps you. – Krishnanshu Gupta May 10 '18 at 04:05
  • The only other thing I can find is to change your region setting(which you said you've done) and to change your japanese fonts back to english(for all other ide's, word, etc; don't know about eclipse though) – Krishnanshu Gupta May 10 '18 at 04:08

0 Answers0