List of usage examples for java.util ResourceBundle getBundle
@CallerSensitive public static final ResourceBundle getBundle(String baseName)
From source file:com.alibaba.otter.shared.common.utils.code.ResourceBundleUtil.java
/** * ResourceBundleUtil,?bundle// w w w . j a v a 2s.c om * * @param bundleName ??? * @throws MissingResourceException ??,? */ public ResourceBundleUtil(String bundleName) { this.bundle = ResourceBundle.getBundle(bundleName); }
From source file:by.logscanner.LogScanner.java
public void init() throws IOException { ResourceBundle resBundle = ResourceBundle.getBundle("config"); resPath = resBundle.getString("resPath"); destPath = resBundle.getString("destPath"); FileUtils.cleanDirectory(new File(destPath)); if (!isGateway()) { walk(resPath);//from w w w.ja v a2 s. co m fileData.add(new FileData(getDestFileName(), toBytes())); } else { walkGateway(resPath); } write(); }
From source file:cn.mypandora.controller.MyUpload.java
/** * @param part/* ww w .ja v a 2 s.co m*/ * @return void * @Title: upload * @Description: */ @RequestMapping(value = "/upload", method = RequestMethod.POST) public void upload(@RequestParam("myFile") Part part, @RequestParam("choosePath") String choosePath) { try { /* ? */ /* ? */ ResourceBundle resourceBundle = ResourceBundle.getBundle("upload"); String savePath = resourceBundle.getString(choosePath != null ? choosePath : "defaultPath") + getFileName(part); // String webRootPath = request.getServletContext().getRealPath("/upload"); String webRootPath = System.getProperty("contentPath"); part.write(webRootPath + savePath); // ?? UploadFile file = new UploadFile(); file.setFileSize(part.getSize()); file.setFileName(getFileName(part)); file.setSaveName(getFileName(part)); file.setFileType(1); file.setSavePath(savePath); file.setCreateTime(new Timestamp(1234567890L)); file.setUpdateTime(new Timestamp(1234567891L)); baseUploadService.saveFile(file); // return file; } catch (IOException e) { throw new RuntimeException(e); } }
From source file:org.jaqpot.core.service.client.jpdi.JPDIClientFactory.java
@PostConstruct public void init() { CloseableHttpAsyncClient asyncClient = HttpAsyncClientBuilder.create().build(); this.client = new JPDIClientImpl(asyncClient, serializer, featureHandler, ResourceBundle.getBundle("config").getString("ServerBasePath")); }
From source file:com.thomaskuenneth.openweathermapweather.BasicView.java
public BasicView(String name) { super(name);/* w ww. j a v a 2s . co m*/ bundle = ResourceBundle.getBundle("com.thomaskuenneth.openweathermapweather.strings"); city = new TextField(); city.setFloatText(bundle.getString("hint")); Button show = new Button(bundle.getString("anzeigen")); image = new ImageView(); temperatur = new Text(); beschreibung = new Text(); VBox texts = new VBox(temperatur, beschreibung); HBox hb1 = new HBox(10, image, texts); hb1.setPadding(new Insets(10, 0, 0, 0)); hb1.setAlignment(Pos.TOP_LEFT); show.setOnAction(e -> doIt()); VBox controls = new VBox(10, city, show, hb1); controls.setPadding(new Insets(14, 14, 14, 14)); controls.setAlignment(Pos.TOP_LEFT); setCenter(controls); }
From source file:com.ibm.amc.data.ErrorResponseTest.java
@Test public void testExplanation() { ResourceBundle bundle = ResourceBundle.getBundle(Constants.CWZBA_BUNDLE_NAME); assertTrue(responseJson.contains("\"explanation\":\"" + bundle.getString(KEY + ".explanation") + "\"")); }
From source file:ca.uhn.fhir.i18n.HapiLocalizer.java
protected void init() { for (String nextName : myBundleNames) { myBundle.add(ResourceBundle.getBundle(nextName)); } }
From source file:es.mityc.firmaJava.policy.PoliciesManager.java
/** * Constructor.//from ww w .j a v a 2s. co m * */ private PoliciesManager() { // Carga las propiedades try { props = ResourceBundle.getBundle(POLICY_FILE_CONF); } catch (MissingResourceException ex) { logger.error(LIBRERIAXADES_POLICY_MANAGER_NO_FILE); } }
From source file:eu.dasish.annotation.backend.rest.ProjectInfoResource.java
/** * /*from w w w .ja va 2 s .c o m*/ * @return a message string containing the number of the version of the backend. * @throws IOException if getting a principal or sending an error fails. */ @GET @Produces(MediaType.TEXT_PLAIN) @Path("version") @Transactional(readOnly = true) public String getVersion() throws IOException { Number principalID = this.getPrincipalID(); String retVal = "?.?"; ResourceBundle rb; try { rb = ResourceBundle.getBundle("projectinfo"); retVal = rb.getString("application.version"); } catch (MissingResourceException e) { httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND, e.getMessage()); } return "DWAN backend " + retVal; }
From source file:net.pflaeging.PortableSigner.SignCommandLine.java
/** Creates a new instance of CommandLine */ public SignCommandLine(String args[]) { langcodes = ""; java.util.Enumeration<String> langCodes = ResourceBundle .getBundle("net/pflaeging/PortableSigner/SignatureblockLanguages").getKeys(); while (langCodes.hasMoreElements()) { langcodes = langcodes + langCodes.nextElement() + "|"; }//from ww w.j a v a 2 s . c om langcodes = langcodes.substring(0, langcodes.length() - 1); // System.out.println("Langcodes: " + langcodes); CommandLine cmd; Options options = new Options(); options.addOption("t", true, rbi18n.getString("CLI-InputFile")); options.addOption("o", true, rbi18n.getString("CLI-OutputFile")); options.addOption("s", true, rbi18n.getString("CLI-SignatureFile")); options.addOption("p", true, rbi18n.getString("CLI-Password")); options.addOption("n", false, rbi18n.getString("CLI-WithoutGUI")); options.addOption("f", false, rbi18n.getString("CLI-Finalize")); options.addOption("h", false, rbi18n.getString("CLI-Help")); options.addOption("b", true, rbi18n.getString("CLI-SigBlock") + langcodes); options.addOption("i", true, rbi18n.getString("CLI-SigImage")); options.addOption("c", true, rbi18n.getString("CLI-SigComment")); options.addOption("r", true, rbi18n.getString("CLI-SigReason")); options.addOption("l", true, rbi18n.getString("CLI-SigLocation")); options.addOption("e", true, rbi18n.getString("CLI-EmbedSignature")); options.addOption("pwdfile", true, rbi18n.getString("CLI-PasswdFile")); options.addOption("ownerpwd", true, rbi18n.getString("CLI-OwnerPasswd")); options.addOption("ownerpwdfile", true, rbi18n.getString("CLI-OwnerPasswdFile")); options.addOption("z", false, rbi18n.getString("CLI-LastPage")); CommandLineParser parser = new PosixParser(); HelpFormatter usage = new HelpFormatter(); try { cmd = parser.parse(options, args); input = cmd.getOptionValue("t", ""); output = cmd.getOptionValue("o", ""); signature = cmd.getOptionValue("s", ""); password = cmd.getOptionValue("p", ""); nogui = cmd.hasOption("n"); help = cmd.hasOption("h"); finalize = !cmd.hasOption("f"); sigblock = cmd.getOptionValue("b", ""); sigimage = cmd.getOptionValue("i", ""); comment = cmd.getOptionValue("c", ""); reason = cmd.getOptionValue("r", ""); location = cmd.getOptionValue("l", ""); embedParams = cmd.getOptionValue("e", ""); pwdFile = cmd.getOptionValue("pwdfile", ""); ownerPwdString = cmd.getOptionValue("ownerpwd", ""); ownerPwdFile = cmd.getOptionValue("ownerpwdfile", ""); lastPage = !cmd.hasOption("z"); if (cmd.getArgs().length != 0) { throw new ParseException(rbi18n.getString("CLI-UnknownArguments")); } } catch (ParseException e) { System.err.println(rbi18n.getString("CLI-WrongArguments")); usage.printHelp("PortableSigner", options); System.exit(3); } if (nogui) { if (input.equals("") || output.equals("") || signature.equals("")) { System.err.println(rbi18n.getString("CLI-MissingArguments")); usage.printHelp("PortableSigner", options); System.exit(2); } if (!help) { if (password.equals("")) { // password missing if (!pwdFile.equals("")) { // read the password from the given file try { FileInputStream pwdfis = new FileInputStream(pwdFile); byte[] pwd = new byte[1024]; password = ""; try { do { int r = pwdfis.read(pwd); if (r < 0) { break; } password += new String(pwd); password = password.trim(); } while (pwdfis.available() > 0); pwdfis.close(); } catch (IOException ex) { } } catch (FileNotFoundException fnfex) { } } else { // no password file given, read from standard input System.out.print(rbi18n.getString("CLI-MissingPassword")); Console con = System.console(); if (con == null) { byte[] pwd = new byte[1024]; password = ""; try { do { int r = System.in.read(pwd); if (r < 0) { break; } password += new String(pwd); password = password.trim(); } while (System.in.available() > 0); } catch (IOException ex) { } } else { // Console not null. Use it to read the password without echo char[] pwd = con.readPassword(); if (pwd != null) { password = new String(pwd); } } } } if (ownerPwdString.equals("") && ownerPwdFile.equals("")) { // no owner password or owner password file given, read from standard input System.out.print(rbi18n.getString("CLI-MissingOwnerPassword") + " "); Console con = System.console(); if (con == null) { byte[] pwd = new byte[1024]; String tmppassword = ""; try { do { int r = System.in.read(pwd); if (r < 0) { break; } tmppassword += new String(pwd, 0, r); tmppassword = tmppassword.trim(); } while (System.in.available() > 0); } catch (java.io.IOException ex) { // TODO: perhaps notify the user } ownerPwd = tmppassword.getBytes(); } else { // Console not null. Use it to read the password without echo char[] pwd = con.readPassword(); if (pwd != null) { ownerPwd = new byte[pwd.length]; for (int i = 0; i < pwd.length; i++) { ownerPwd[i] = (byte) pwd[i]; } } } } else if (!ownerPwdString.equals("")) { ownerPwd = ownerPwdString.getBytes(); } else if (!ownerPwdFile.equals("")) { try { FileInputStream pwdfis = new FileInputStream(ownerPwdFile); ownerPwd = new byte[0]; byte[] tmp = new byte[1024]; byte[] full; try { do { int r = pwdfis.read(tmp); if (r < 0) { break; } // trim the length: tmp = Arrays.copyOfRange(tmp, 0, r); //System.arraycopy(tmp, 0, tmp, 0, r); full = new byte[ownerPwd.length + tmp.length]; System.arraycopy(ownerPwd, 0, full, 0, ownerPwd.length); System.arraycopy(tmp, 0, full, ownerPwd.length, tmp.length); ownerPwd = full; } while (pwdfis.available() > 0); pwdfis.close(); } catch (IOException ex) { } } catch (FileNotFoundException fnfex) { } } } } if (!embedParams.equals("")) { String[] parameter = null; parameter = embedParams.split(","); try { Float vPosF = new Float(parameter[0]), lMarginF = new Float(parameter[1]), rMarginF = new Float(parameter[2]); vPos = vPosF.floatValue(); lMargin = lMarginF.floatValue(); rMargin = rMarginF.floatValue(); noSigPage = true; } catch (NumberFormatException nfe) { System.err.println(rbi18n.getString("CLI-embedParameter-Error")); usage.printHelp("PortableSigner", options); System.exit(5); } } if (!(langcodes.contains(sigblock) || sigblock.equals(""))) { System.err.println(rbi18n.getString("CLI-Only-german-english") + langcodes); usage.printHelp("PortableSigner", options); System.exit(4); } if (help) { usage.printHelp("PortableSigner", options); System.exit(1); } // System.err.println("CMDline: input: " + input); // System.err.println("CMDline: output: " + output); // System.err.println("CMDline: signature: " + signature); // System.err.println("CMDline: password: " + password); // System.err.println("CMDline: sigblock: " + sigblock); // System.err.println("CMDline: sigimage: " + sigimage); // System.err.println("CMDline: comment: " + comment); // System.err.println("CMDline: reason: " + reason); // System.err.println("CMDline: location: " + location); // System.err.println("CMDline: pwdFile: " + pwdFile); // System.err.println("CMDline: ownerPwdFile: " + ownerPwdFile); // System.err.println("CMDline: ownerPwdString: " + ownerPwdString); // System.err.println("CMDline: ownerPwd: " + ownerPwd.toString()); }