Morse code translator help reading from file
<p>Okay so I know there are other Morse code answers out there, but I have looked at many, but none of them worked. For my assignment I was to read a file, Morse.txt, into parallel arrays. Instead I just made two files, Morse.txt and Alphabet.txt one with code and the other with numbers and alphabet. I am supposed to use a class I made to do the translating part and when called in main it should translate user input. I can't seem to get this working. I've tried so many things from using a toString in the class or getter, but the return is not found when I put in the loop which I think has to be there(if that makes sense)..anyway here is my code for main:</p>

<pre><code>import java.util.*;
import java.util.Scanner;
import java.io.*;

public class redo
{
    public static void main(String[]args) throws IOException
    {
        String line2, file2 = "Morse.txt";
        String line, file = "Alphabet.txt";

        File openFile = new File(file);
        File openFile2 = new File(file2);

        Scanner inFile = new Scanner(openFile);
        Scanner inFile2 = new Scanner(openFile2);

        int index = 36;
        char[] charArray = new char[index]; 
        String[] code = new String[index];

        for(index = 0; index &lt; 36; index++)
        {   
            while(inFile.hasNext())
            {
                    line = inFile.nextLine();
                    charArray = line.toCharArray();
                    //System.out.println(charArray[index]);
            }
        }       

        for(index = 0; index &lt; 36; index++)
        {
            while(inFile2.hasNext())
            {
                code[index] = inFile2.nextLine();
                //System.out.println(code[index]);
            }
        }

        Scanner keyboard = new Scanner(System.in);

        String userInput;

        System.out.println("Enter something to translate: ");
        userInput= keyboard.nextLine();

        Translate inputTranslate = new Translate(userInput);

        inputTranslate.setInput(userInput);

        inputTranslate.setAlph(charArray);
        inputTranslate.setCode(code);

        inFile.close();
    }
}
</code></pre>

<p>and here is my class Translate(some things are commented out):</p>

<pre><code>public class Translate
{
    String input;
    String code[];
    char alph[];

    public Translate(String input)
    {
        this.input = input;
    }

    public void setInput(String input)
    {
        this.input = input;
    }

    public void setAlph(char[] alph)
    {
        this.alph = alph;
    }

    public void setCode(String[] code)
    {
        this.code = code;
    }

    public String getInput()
    {
        return input;
    }

//  public String getTranslate()
//  {
//      for(int i = 0; i &lt; input.length(); i++)
//      {
//          for(int index = 0; index &lt; alph.length; index++)
//          {
//              if(input.charAt(i) == alph[index])
//              {
//                  String output = code[index];
//              }
//          }
//      }
//      return output;
//  }


}
</code></pre>

<p>Morse.txt:</p>

<p>.----
..---
...--
....-
.....
-....
--...
---..</p>

<h2>----.</h2>

<p>.-
-...
-.-.
-..
.
..-.
--.
....
..
.---
-.-</p>

<h2>.-..</h2>

<h2>-.</h2>

<p>.--.
--.-
.-.</p>

<h2>...</h2>

<p>..-
...-
.--
-..-
-.--
--..</p>

<p>Alphabet.txt:
1
2
3
4
5
6
7
8
9
0
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z</p>
