Click here to Skip to main content
15,904,348 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am writing a ROT13 java program. I am very new to java. I am wondering how to make it so my output is all in 6 character chunks. I tried % 6 but it would count the spaces as a character. Any suggestions?

What I have tried:

I tried doing,
Java
if ((something.charAt(x++) % 6) == 0)
                  System.out.print(" ");

and things similar to that.
Posted
Updated 18-Feb-18 18:22pm
v2
Comments
PIEBALDconsult 17-Feb-18 23:48pm    
You should be removing any existing SPACEs.

you can use try this
Java
Character.isWhitespace
please refer to this article on stack overflow this may help you out.
 
Share this answer
 
v2
Well, if you can do it by first removing all the spaces using this
string.replaceAll(" ","");
and after you're done with removing all the spaces just get on with searching and retrieval as usual.
Hope this helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900