I have a little bit of problems with the .split() funtion.
To make things short, I have this lines with words like: A.HelloWorld.D
Now there are also words that have: A.HelloWorld.
What I would like is that when there is nothing after the second dot (.) that the program will print a " ". But I don't know how to do that?
Becose I also would like to do something with it outside the if else part.
Sounds like a job for replaceAll().
There's also a two argument split( ... ) method (it's API doc description is below the one argument split( ... ) method). It can do the job ...
I found the solution!
Thanks for the help. :-)
Where was it hiding?
Originally Posted by Lund01
I needed a -1 behind it.
Like .split("\\.", -1)
And then he also sees the 'blank' spaces.
If the line before the second dot is always the same, you could also use .substring to get the remainder. It'd mean that you'd have to change the code if the input changes though, which isn't always optimal.