Hi!
I need help with a class project. It is basically an encoder/decoder program, with two parts.
Part 1: Take text entered by a user, convert each character to a number, and save the result to a file.
Part 2: Read each number from the file, convert it to a character, and display the result in a message box.
Here is what I have so far:
public class Oliver_Final_v2a
{
static Scanner console = new Scanner(System.in);
public static void main (String[] args) throws FileNotFoundException
{
String msg="";
String outputStr ="";
PrintWriter outFile = new PrintWriter("Oliver_Encoded.txt");
msg = JOptionPane.showInputDialog("Enter (or paste) the text: ");
for (int i = 0; i < msg.length(); i++)
{
outFile.println((int)(msg.charAt(i)-1));
}
outFile.close();
}
The first part was easy, but I don't know how to get the numbers from the file and convert them into characters. A few websites I found while researching this mentioned a tokenizer, but that's not covered in my textbook, and I have no idea how to implement it.
Thanks in advance for any help! :)