[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 190
  • Last Modified:

null char elimination

the program i'm working with will display two file names, null is in the name, how do i get that out?
nullfilename1
nullfilename2

I think it with this line of code that things are getting messed up
if(sorter1[i].charAt(i) != ' ') {

Since ' ' does not = null and you can't have null == char, i'm not sure what will work

Suggestions?
0
no158
Asked:
no158
  • 5
  • 2
1 Solution
 
CEHJCommented:
Try

s = s.replace("\x0", "");
0
 
CEHJCommented:
Should be replaceAll
0
 
CEHJCommented:
s = s.replaceAll("\0", "");

works well enough
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
no158Author Commented:
I'm working with a String array
sorter1[i] = sorter[i].replaceAll("\0", "");

is giving me output that looks like:
nullfilename1
nullfilename2
0
 
CEHJCommented:
>>is giving me output that looks like:

Not sure what your point is ...
It will eliminate null chars
0
 
no158Author Commented:
Off set the string by 4 char's and it fixed this problem, for some reason the replaceAll code was not doing its job deep within loops. Ill have to fine comb this later but for now I need to have a working product.
0
 
CEHJCommented:
:-)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now