Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Program in Java that works like StringTokinizer that divides a sentence into characters

  1. #1
    Junior Member
    Join Date
    Jul 2008
    Location
    Hamilton, New Zealand
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Program in Java that works like StringTokinizer that divides a sentence into characters

    Hi Guys,

    Im a 2nd year IT student doing my bachelors degree in New Zealand. So I was wondering... is there something in Java that works like StringTokinizer but divides a sentence into characters? I know its possible I just dont know how. I basically want to try and make and encoder that encodes normal .txt documents.

    Thanks!


  2. #2
    Banned
    Join Date
    May 2008
    Posts
    25
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Tokinizers

    Hi, welcome to the forums!

    This is one way to do it:

    public class CharDemo {
        public static void main(String[] args){
     
            String sentence = "This is a sentence";
            char[] charSentence = sentence.toCharArray();
            for(int i = 0; i < sentence.length(); i++){
                System.out.print(charSentence[i]);
            }
        }
    }

  3. #3
    Junior Member
    Join Date
    Jul 2008
    Location
    Hamilton, New Zealand
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Tokinizers

    Thank you so much that really helps alot! I think we can call this one solved!

    Cheers guys