2013年9月3日星期二

The value of the String class value the role of the judge for anempty String



String how such a judgment is empty . .
because after all, s = ""

And value may also have more than one value as



json just my name from the program to the here and json irrelevant.
------ Solution ---------------------------------------- ----

      
s.equals (""); and s.isEmpty (); same bar that this is not acceptable then count = 1      
    
    Since the count is 1
    
not necessarily that which is really empty , but there may be an unknown special characters ,     
At least you got to come out of this s how to tell about it , or how to know whether it is empty inside it . .    
  
  
  
  
				StringBuilder sb = new StringBuilder();
for (String s = reader.readLine(); s != null; s = reader
.readLine())
{
sb.append(s);
}
  
  
read a completely empty pages  

really do not know how it comes out . .

public static void main(String[] args) throws Exception {
FileReader fr=new FileReader(new File("D:\\tttt.html"));
BufferedReader reader=new BufferedReader(fr);
StringBuilder sb = new StringBuilder();
//这个for循环根本就没有执行。。
for (String s = reader.readLine(); s != null; s = reader.readLine())
{
    sb.append(s);
}
System.out.println(sb.toString());
}

------ For reference only ----------------------------------- ----
s.equals ("");
This trip
empty string and null is not a concept . .

Question 2 which together no matter how many empty after should still be a blank. .
------ For reference only -------------------------------------- -
using tools like apache bar
org.apache.commons.lang.StringUtils
------ For reference only ------------------------- --------------
value seemingly breakpoint view values ​​to see is something like an array

------ For reference only ---------------------------------- -----


s.equals (""); and s.isEmpty (); same bar that this is not acceptable count = 1 it
------ For reference only - -------------------------------------

  
s.equals (""); and s.isEmpty (); same bar that this is not acceptable then count = 1  
Since the count is 1

not necessarily that which is really empty , but there may be an unknown special characters ,
At least you got to come out of this s how to tell about it , or how to know whether it is empty inside it . .
------ For reference only -------------------------------------- -

    
s.equals (""); and s.isEmpty (); same bar that this is not acceptable then count = 1    
  
  Since the count is 1
  
not necessarily that which is really empty , but there may be an unknown special characters ,   
At least you got to come out of this s how to tell about it , or how to know whether it is empty inside it . .  


				StringBuilder sb = new StringBuilder();
for (String s = reader.readLine(); s != null; s = reader
.readLine())
{
sb.append(s);
}


read a completely empty pages
------ For reference only --------------------------- ------------

  
s.equals (""); and s.isEmpty (); same bar that this is not acceptable then count = 1  

general we are such judgments :
null! = s && "". equals (s)

s.isEmpty (), accidentally ran null

没有评论:

发表评论