Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- public class MorseCode {
- private HashMap<String, Character> helperMap = new HashMap<>();
- private TreeMap<Character, String> toCode = new TreeMap<>();
- private ArrayList<String> helperList = new ArrayList<>();
- private void encodeFile(String inputFileName, String outputFileName) throws Exception {
- }
- private void decodeFile(String inputFilename, String outputFileName) {
- }
- private void writeFile(String morse) {
- PrintWriter output = null;
- try {
- Scanner in = new Scanner(System.in);
- // A printWriter works just like standard output
- output = new PrintWriter(new FileOutputStream("testPrintwriter"));
- // We copy data from the keyboard to the file
- System.out.print("Enter some text");
- String data = in.nextLine();
- while (!data.equals("done")) {
- output.println(data);
- System.out.print("Enter some more text (\"done\" to exit)");
- data = in.nextLine();
- }
- } catch (IOException e) {
- System.out.println(e);
- } finally {
- output.close();
- }
- }
- private void readMorseCode(File name) {
- try {
- Scanner sc = new Scanner(name);
- while (sc.hasNextLine()) {
- Character c = sc.next().charAt(0);
- String s = sc.next();
- helperMap.put(s, c);
- }
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- }
- }
- TreeMap<String, Character> newMap = new TreeMap<>();
- Character sorry[] = {'E','T','I','A','N','M','S','U','R','W','D','K','G','O','H','V','F','L','P','J','B','X','C','Y','Z','Q'};
- private void makeList() {
- helperList.addAll(helperMap.keySet());
- Collections.sort(helperList);
- newMap.put("", ' ');
- for (String s : helperList) {
- for (int i = 0; i < s.length(); i++) {
- if (s.charAt(i) == '-'){
- }
- }
- }
- System.out.println(newMap);
- }
- public static void main(String[] args) {
- MorseCode mc = new MorseCode();
- mc.readMorseCode(new File("MorseCode.txt"));
- mc.makeList();
- System.out.println("hello world");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement