import java.io.*;
import java.net.*;
import java.lang.*;
import java.math.*;
import java.nio.charset.*;
import java.nio.file.*;
import java.util.*;

public class JMinusMinus {

    public static void main(String[] a){
        String file = a[0];
        StringBuilder jCode = new StringBuilder();
        jCode.append("import java.io.*;import java.net.*;import java.lang.*;import java.math.*;import java.util.*;");
        jCode.append("public class J{");
        String b = readFile(file);
        b = replaceAll(b, "fn", "public static");
        b = replaceAll(b, "str", "String");
        b = replaceAll(b, "dub", "double");
        b = replaceAll(b, "fpn", "float");
        b = replaceAll(b, "nop", "void");
        b = replaceAll(b, "dub", "double");
        b = replaceAll(b, "echo", "System.out.println");
        b = replaceAll(b, "^^", "!=");
        b = replaceAll(b, "nw", "new");
        jcode.append(b);
        jCode.append("}//Bracket for class");
        writeFile("J.java", jCode.toString());
    }

    public static String replaceAll(String source, String from, String to){
        return source.replaceAll(from + "(?![^"]*"(?:[^"]*"[^"]*")*[^"]*$)", " " + to + " ");
    }

    public static String readFile(String path) throws IOException {
        byte[] encoded = Files.readAllBytes(Paths.get(path));
        return new String(encoded, StandardCharsets.UTF_8);
    }

    public static void writeFile(String path, String output) {
        PrintWriter writer = null;
        try {
            writer = new PrintWriter(path, "UTF-8");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        writer.print(output);
        writer.close();
    }

}

@@ -178,720 +178,798 @@
     
-public static void main(String%5B%5D a)%7B%0A        String file = a%5B0%5D;%0A        StringBuilder jCode = new StringBuilder();%0A        jCode.append(%22import java.io.*;import java.net.*;import java.lang.*;import java.math.*;import java.util.*;%22);%0A        jCode.append(%22public class J%7B%22);%0A        String b = readFile(file);%0A        b = replaceAll(b, %22fn%22, %22public static%22);%0A        b = replaceAll(b, %22str%22, %22String%22);%0A        b = replaceAll(b, %22dub%22, %22double%22);%0A        b = replaceAll(b, %22fpn%22, %22float%22);%0A        b = replaceAll(b, %22nop%22, %22void%22);%0A        b = replaceAll(b, %22dub%22, %22double%22);%0A        b = replaceAll(b, %22echo%22, %22System.out.println%22);%0A        b = replaceAll(b, %22%5E%5E%22, %22!=%22);%0A        b = replaceAll(b, %22nw%22, %22new%22);
+static HashMap%3CString, String%3E replacements = new HashMap%3CString, String%3E()%7B%7B%0A        put(%22fn%22, %22public static%22);%0A        put(%22str%22, %22String%22);%0A        put(%22dub%22, %22double%22);%0A        put(%22fpn%22, %22float%22);%0A        put(%22vd%22, %22void%22);%0A        put(%22echo%22, %22System.out.println%22);%0A        put(%22%5E%5E%22, %22!=%22);%0A        put(%22nw%22, %22new%22);%0A        put(%22map%22, %22HashMap%22);%0A    %7D%7D;%0A%0A%0A    public static void main(String%5B%5D a)%7B%0A        String file = a%5B0%5D;%0A        StringBuilder jCode = new StringBuilder();%0A        jCode.append(%22import java.io.*;import java.net.*;import java.lang.*;import java.math.*;import java.util.*;%22);%0A        jCode.append(%22public class J%7B%22);%0A        String b = readFile(file);%0A        for(String s : replacements.keySet())%7B%0A            b = replaceAll(b, s, replacements.get(s));%0A        %7D
 %0A   
@@ -1203,16 +1203,22 @@
 All(
+%22(%22 + 
 from + %22
 (?!%5B
@@ -1213,16 +1213,17 @@
 from + %22
+)
 (?!%5B%5E%22%5D*

put replacements into a hashmap