Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

backslash added while reading File

managed BEANFeb 20 2018 — edited Feb 27 2018

Hello,

I am reading a file:

FileReader fr = null;

BufferedReader br = null;

fr = new FileReader(this.resource.toString());

br = new BufferedReader(fr);

String sCurrentLine;

String fullFile = "";

while (null != (sCurrentLine = br.readLine())) {

System.out.println("line" + sCurrentLine);

fullFile += sCurrentLine + "\n";

}

The original file content is:

#tue Feb 20 08:40:24 WET 2018

DataEngineFactory=dummy.app.EngineFactory

PersistCache=false

LoginLocale=en_GBbrand

ServiceRoot=https://nextgen-wlws.conceptsoftware.eu:9075/

SessionTimeout=3600

Debug=true

CustProvider=true

CacheSize=1000

But in console log it is printing:

pastedImage_1.png

If you see the ServiceRoot property (which is supposed to be an URL) it added backslashes before ':' (do not mind the LoginLocale property, it was deliberately changed to teste).

Why is that happening.

I thought it could be the BufferedReader class, but i tried with others too and all give same output:

//with scanner

Scanner sc = new Scanner(this.resource);

while (sc.hasNextLine()) {

sCurrentLine = sc.nextLine();

System.out.println("scanner" + sCurrentLine);

fullFile += sCurrentLine + "\\n";

}

//with apache commons

fullFile = FileUtils.readFileToString(new File(this.resource.toString()));

Can you help me?

Thanks

Carlos

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 21 2018
Added on Feb 20 2018
5 comments
974 views