You should wrap your code with reading and replacing into loop. Something like this:
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
public class MorseCode {
public static void main(String[] args) throws IOException {
String characters[] = {"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", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"};
int counter1 = 0;
Scanner inFile = new Scanner(new File("morseCode.txt"));
String morseCharacter[] = new String[(characters.length)];
while (inFile.hasNextLine() && counter1 < (characters.length)) {
morseCharacter[counter1] = inFile.nextLine();
morseCharacter[counter1] += " ";
counter1++;
}
for (int x = 0; x < (morseCharacter.length); x++) {
System.out.println(characters[x] + " = " + morseCharacter[x]);
}
Scanner in = new Scanner(System.in);
System.out.print("\nEnter a phrase you wish to translate to morse: ");
while (in.hasNextLine()) {
String line = in.nextLine();
for (int x = 0; x < (morseCharacter.length); x++) {
line = line.replaceAll(characters[x], morseCharacter[x]);
}
System.out.println(line);
}
}
}