Hello, help. I read a line from a file and now I need to break it into words by a space, just in the word swap letters and write to a file. How can you break into words and swap letters (no matter what, just for example)?
public static void main(String[] args) throws IOException { String text = new String(); Scanner in = new Scanner(new File("text.txt")); while (in.hasNext()) { text += in.nextLine(); } in.close(); char[] words; char line; String delimeter = " "; words = text.toCharArray(); FileWriter writer = new FileWriter("crypt.txt"); for (int i = 0; i < words.length; i++) { if(words[i] == ' ') { System.out.print(words[i]); break; } } } I tried to print at least the first letters before the space, but it did not work.