private void saveCurrent() { PrintWriter writer = null; try { writer = new PrintWriter("config.txt", "UTF-8"); writer.println("PhoneNumbers:"); for (String s : Main.getEmails()) { writer.println(s); } writer.println("Items:"); for (Item s : Main.getItems()) { writer.println(s.getName() + "," + s.getWebsite()); } results.setText("Current settings have been saved sucessfully."); } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); } writer.close(); }
/** * 访问服务器环境 * * @param names 参数名字 * @param values 参数值 */ public static void visitEnvServerByParameters(String[] names, String[] values) { int len = Math.min(ArrayUtils.getLength(names), ArrayUtils.getLength(values)); String[] segs = new String[len]; for (int i = 0; i < len; i++) { try { // 设计器里面据说为了改什么界面统一, 把分隔符统一用File.separator, 意味着在windows里面报表路径变成了\ // 以前的超链, 以及预览url什么的都是/, 产品组的意思就是用到的地方替换下, 真恶心. String value = values[i].replaceAll("\\\\", "/"); segs[i] = URLEncoder.encode(CodeUtils.cjkEncode(names[i]), EncodeConstants.ENCODING_UTF_8) + "=" + URLEncoder.encode(CodeUtils.cjkEncode(value), "UTF-8"); } catch (UnsupportedEncodingException e) { FRContext.getLogger().error(e.getMessage(), e); } } String postfixOfUri = (segs.length > 0 ? "?" + StableUtils.join(segs, "&") : StringUtils.EMPTY); if (FRContext.getCurrentEnv() instanceof RemoteEnv) { try { if (Utils.isEmbeddedParameter(postfixOfUri)) { String time = Calendar.getInstance().getTime().toString().replaceAll(" ", ""); boolean isUserPrivilege = ((RemoteEnv) FRContext.getCurrentEnv()).writePrivilegeMap(time, postfixOfUri); postfixOfUri = isUserPrivilege ? postfixOfUri + "&fr_check_url=" + time + "&id=" + FRContext.getCurrentEnv().getUserID() : postfixOfUri; } String urlPath = getWebBrowserPath(); Desktop.getDesktop().browse(new URI(urlPath + postfixOfUri)); } catch (Exception e) { FRContext.getLogger().error("cannot open the url Successful", e); } } else { try { String web = GeneralContext.getCurrentAppNameOfEnv(); String url = "http://localhost:" + DesignerEnvManager.getEnvManager().getJettyServerPort() + "/" + web + "/" + ConfigManager.getProviderInstance().getServletMapping() + postfixOfUri; StartServer.browerURLWithLocalEnv(url); } catch (Throwable e) { // } } }
private void savePhone() { if (phone.getText().length() == 10) { File f = new File("config.txt"); Scanner sc; ArrayList<String> config = new ArrayList<String>(); try { sc = new Scanner(f); while (sc.hasNext()) { String s = sc.nextLine(); config.add(s); } sc.close(); } catch (FileNotFoundException e2) { results.setText("Error reading config.txt"); } int i = 0; for (String s : config) { if (s.equals("PhoneNumbers:")) { break; } i++; } if (carriers.getSelectedIndex() == 0) { config.add(i + 1, phone.getText() + "@txt.att.net"); } if (carriers.getSelectedIndex() == 1) { config.add(i + 1, phone.getText() + "@myboostmobile.com"); } if (carriers.getSelectedIndex() == 2) { config.add(i + 1, phone.getText() + "@mobile.celloneusa.com"); } if (carriers.getSelectedIndex() == 3) { config.add(i + 1, phone.getText() + "@messaging.nextel.com"); } if (carriers.getSelectedIndex() == 4) { config.add(i + 1, phone.getText() + "@tmomail.net"); } if (carriers.getSelectedIndex() == 5) { config.add(i + 1, phone.getText() + "@txt.att.net"); } if (carriers.getSelectedIndex() == 6) { config.add(i + 1, phone.getText() + "@email.uscc.net"); } if (carriers.getSelectedIndex() == 7) { config.add(i + 1, phone.getText() + "@messaging.sprintpcs.com"); } if (carriers.getSelectedIndex() == 8) { config.add(i + 1, phone.getText() + "@vtext.com"); } if (carriers.getSelectedIndex() == 9) { config.add(i + 1, phone.getText() + "@vmobl.com"); } PrintWriter writer = null; try { writer = new PrintWriter("config.txt", "UTF-8"); for (String s : config) { writer.println(s); } } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (UnsupportedEncodingException e1) { e1.printStackTrace(); } writer.close(); addPhone(); } else { results.setText("Please add 10 digit cell number."); } }