Java applet不支持非ascii /德语字符,如äöü...等

时间:2014-07-17 13:40:54

标签: java windows applet

我想通过传递参数来启动浏览器并使用Java的Runtime exec加载网页。我试图将参数传递给JAVA APPLET的Runtime exec以启动exe。

就我而言,路径“C:\ SW \Dr.JoannaSchöpf-Grey213982 \ IVLS_VS25YWTL1 \ ActivityLog_2014_07.xml”包含字符“ö”。但是,小程序将路径传递为“C:\ SW \ Dr” .JoannaSch pf-Grey213982 \ IVLS_VS25YWTL1 \ ActivityLog_2014_07.xml“(用 替换”ö“德语字符)给Runtime exec。

小程序看起来像这样:

public class LaunchSSCPApplet extends JApplet {

    private static final long serialVersionUID = -9024284603221319628L;
    StringBuffer buffer;
    Process p = null;
    int inException = -1;
    String filesList = null;
    String filePath = null;
    String sapNumber = null;
    List<String> cmdList = new ArrayList<String>();
    private JTextPane textArea;

    public void init() {
        try {
            setupTextPanel();
            buffer = new StringBuffer();
            filePath =  getParameter("exePath");                    
            filesList =  getParameter("filesList");
            sapNumber = getParameter("sapNumber");

            buffer.append("SSCP Executable Path : "+filePath);
            if(filePath != null && !(filePath.trim().equals(""))){
                cmdList.add(filePath);

            }

            if (sapNumber != null && !(sapNumber.trim().equals(""))) {
                cmdList.add("--sap");
                cmdList.add(sapNumber);
            }

            StringTokenizer tokenizer = new StringTokenizer(filesList, "|");
            while(tokenizer.hasMoreTokens()){
                String f = tokenizer.nextToken();

                if (filePath.endsWith(".bat")) {
                    cmdList.add(f);
                } else {
                    cmdList.add("--logfile");
                    cmdList.add("C:/SW/Dr.JoannaSchöpf-Grey213982/IVLS_VS25YWTL1/ActivityLog_2014_07.xml");
                }

                buffer.append("<br>");
                buffer.append("FILE PATH: "+f);
            }

            String [] cmdArray = cmdList.toArray(new String[cmdList.size()]);

            p = Runtime.getRuntime().exec(cmdArray);
            if(filePath.contentEquals(".bat")) {
                p.waitFor();
            }

            /*
             * UnCommenting this as the Applet window has to be closed after launching SSCP
             * Defect: 235626 : Observe the applet does not close after tool is launched
             */
            JSObject win = JSObject.getWindow(this);
            win.eval("window.close()");

        } catch (IOException io) {
            buffer.append("<br>");
            buffer.append("An error occured while loading SSCP " +getStackTraceAsString(io));
        } catch (Exception e) {
            buffer.append("<br>");
            buffer.append("Please contact administrator there is some problem loading application : "+getStackTraceAsString(e));
        }

请帮我解决上述问题。

0 个答案:

没有答案
相关问题