This week's giveaway is in the Programmer Certification (OCPJP) forum.
We're giving away four copies of Java Mock Exams (software) and have David Mayer on-line!
See this thread for details.
Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

NX: null and blank string process

 
frank sun
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I got one problem when processing the null and blank string(""). for example, when writing into the file, how to differ them, and while reading out the record, how to differ them?
Please help!
Best regards!
Frank
 
S. Ganapathy
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi frank,
I really could not understand what u exactly mean by null and String("").
null string basically is the string that coes not have any data like String(""). Internally it is represented as char[] data = new char[0];
where as null is something else, a state where the object is not created.
In the assignment, null terminated string represents String(""). So please do not confuse.
After u read the data from db file, just trim the extra spaces, and while writing to the db file, pad the speces to the maximum lenght of that field.
Ganapathy
 
Bartolo Almeda
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's null right something like 'NULL' to the file and when you're reading check for this before initialazing any data.
 
frank sun
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank at first.
Let me make my question clear.
before inserting a new record into the data file, it needs to check if there already exists the duplicated record, eg, it needs to insert the record, the string array values like("a","","","d"); and in the data file, there has one record like, the string array values is,("a","",null,"d"), so, do I need to take them as the duplicated record? (and when writing the record data into the data file, should all the null values in the record data be regarded as ""?)
Thanks!
Frank
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!