开发者

Java: How is a blank character represented?

开发者 https://www.devze.com 2023-03-15 19:14 出处:网络
I had run a mySql query from ant, and had the output in \"out.txt\". In this file, right after listing the rows in the table, there is:

I had run a mySql query from ant, and had the output in "out.txt". In this file, right after listing the rows in the table, there is:

<-- this line is an empty line

0 ro开发者_运维知识库ws affected

In Java, i am trying take out.txt and make it more readable. I want to ignore the empty line. I have tried: if (!(myStr.contains("\n") ) but it does not work. I have tried "" and null too.

This line is bothering me because when i add some html tags, it is getting in at the very end, and messing up the way the html table looks.


So your workflow is database->ant->out.txt->Java-> what? You want to make an empty line more readable? myStr is a String, from the mySql-Query or from reading the file back in? I would first try

 (myStr != null) 

just to be sure, then

 (myStr.isEmpty ())
 // or 
 (myStr.length () == 0)

If you tried "" - was it (myStr == "") or (myStr.equals (""))?

0

精彩评论

暂无评论...
验证码 换一张
取 消