I'm just playing around with some code and I can't figure out why this isn't working. It's only "encrypting" one word. Can anyone tell me what's wrong with it?

import java.util.*;

public class EncrypterDriver {
	
	static String encrypt(String fileMessage)
	{
		String encryptedMessage = "";
		char fileChar = '0';
		String fileWord = "";
		String encryptedWord;
		StringTokenizer st = new StringTokenizer(fileMessage);
		
		while(st.hasMoreTokens())								//While the fileMessage string has more words in it
		{
			fileWord = st.nextToken();						//Returns word from the fileMessage string and stores it in fileWord
			System.out.println(fileWord);
			encryptedWord = "";							//Resets encrypted word
			
			for(int i = 0; i < fileWord.length() - 1; i++)			//loops through each character in the fileWord string
			{
				fileChar = fileWord.charAt(i);						// returns the character at position "i" from the string fileWord
				fileChar+= 10;										// adds 10 to the character
				encryptedWord +=  fileChar;				// puts the character in the String encryptedMessage
			}
			
			encryptedMessage += encryptedWord + " ";							//stores a word in encrypted word and inserts a space after every word encrypted
			
		}
		
		return encryptedMessage;
	}

	public static void main(String[] args) {
		String message = "";
		String encryptedMessage = "";
		Scanner sc = new Scanner(System.in);
		
		System.out.println("Enter a message: ");
		message = sc.next();
		
		encryptedMessage = encrypt(message);
		
		System.out.println(encryptedMessage);
		
		

	}

}

You are only reading a single word here

message = sc.next();

Use nextLine() to read the entire input line

message = sc.nextLine();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.