Skip to Main Content

New to Java

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!

How to deal with the string value of "null" in a data file

966239Feb 24 2015 — edited Feb 24 2015

HI, I have table data I'm trying to read . However one column is populated with the word "null".

I guess java does not like dealing with the word null and throws errors.

when I try a block like

if ( rsrow.getString(insCol) = "null") {

I get and error .

If I try :

cmp = rsrow.getString(insCol);

If I try:If I try:

if (cmp = "null") {

I get an error

If I try to use a replace function like:

System.out.println(cmp.replace("null", "0"));

just to see if replace works I get and error.

What id the BEST way to replace this string value with something like "0"  when I come across it with out jave throwing an error?

I want it such that every time I come across the word "null" I can repalce it with "0".

Something like:

if (rsrow.getString(insCol) = "null") {
rowofdata = rowofdata + "'0',";
  } else {
rowofdata = rowofdata + "'" + rsrow.getString(insCol) + "',";
}

Thanks,

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 24 2015
Added on Feb 24 2015
2 comments
889 views