check out what i do, string tokenizer is used to break up a string by sub strings
not b char's. lets say is u have a string like this
"my name is ceasar"
if u use the string tokenizer then this would be 4 strings given that u use the
delimiter to be a empty space.
my
name
is
ceasar
lets say for example
StringTokenizer st = new StringTokenizer("my name is ceasar"," ", false);
while( st.hasMoreTokens() )
System.out.println(st.nextToken());
in the above 3 lines this should tell all on how to use the string tokenizer.
here is a sample of how to encypt using the ceasar cipher but i did the the
encrypt part the decrypt i leave to u.
import javax.swing.*;
public class ceasar2
{
private String inputString;
private int intOffset;
public ceasar2()
{
inputString = null;
intOffset = 0;
}
public static void main(String [] args)
{
ceasar2 c2 = new ceasar2();
String tmp = c2.encrypt();
System.out.println( tmp );
//System.out.println( decrypt( tmp ) );
System.exit(0);
}
public String encrypt()
{
inputString = ((String)JOptionPane.showInputDialog("enter string to encrypt") ).toLowerCase().trim();
intOffset = Integer.parseInt(JOptionPane.showInputDialog("enter offset") );
String letters = "abcdefghijklmnopqrstuvwxyz";
StringBuffer sb = new StringBuffer();
int holder = inputString.length();
for(int i = 0; i < holder; i++)
{
String tmp = ""+inputString.charAt(i);
int offset = letters.indexOf(tmp);
offset += intOffset;
if( offset > 25 )
{
int newOffset = 0;
newOffset = offset % 25;
sb.append( letters.charAt(newOffset) );
}
else
{
sb.append( letters.charAt(offset) );
}
//
}//forloop
return sb.toString();
}
/*
public String decrypt( String input )
{
}
*/
}//class
try it to decrypt u will have to work backwords with the same offset that u encrypted , but i leave that up to u.