List of usage examples for java.util MissingResourceException printStackTrace
public void printStackTrace()
From source file:MainClass.java
public static void main(String args[]) throws Exception { ResourceBundle resources;/* w w w.j a v a 2 s .c o m*/ try { resources = ResourceBundle.getBundle("MyData"); System.out.println(resources.getString("Hi")); } catch (MissingResourceException e) { e.printStackTrace(); System.err.println("MyData.properties not found"); } }
From source file:Animals.java
public static void main(String[] argv) { ResourceBundle animalResources; try {//from w ww. ja va 2s .c om animalResources = ResourceBundle.getBundle("AnimalResources", Locale.getDefault()); System.out.println(animalResources.getString("Animals")); } catch (MissingResourceException mre) { mre.printStackTrace(); } }
From source file:HelloResourceBundleExample.java
public static void main(String [] argv) { try {//from w w w .j a v a 2 s . co m Locale frenchLocale = new Locale("fr", "FR"); ResourceBundle rb = ResourceBundle.getBundle("HelloResourceBundle", frenchLocale); System.out.println(rb.getString("Hello")); System.out.println(rb.getString("Goodbye")); } catch (MissingResourceException mre) { mre.printStackTrace(); } }
From source file:Main.java
public static void main(String[] argv) { try {//from w w w. j a v a 2 s .c o m ResourceBundle rb = ResourceBundle.getBundle("SimpleResourceBundle"); System.out.println(rb.getString("AMMessage")); System.out.println(rb.getString("PMMessage")); } catch (MissingResourceException mre) { mre.printStackTrace(); } }
From source file:SimpleResourceBundleExample.java
public static void main(String [] argv) { try {//from w ww .ja v a 2 s.co m ResourceBundle rb = ResourceBundle.getBundle("SimpleResourceBundle"); System.out.println(rb.getString("AMMessage")); System.out.println(rb.getString("PMMessage")); } catch (MissingResourceException mre) { mre.printStackTrace(); } }
From source file:com.example.dhaejong.acp2.MyGcmListenerService.java
/** * Called when message is received./*from ww w.ja v a 2 s . c o m*/ * * @param from SenderID of the sender. * @param data Data bundle containing message data as key/value pairs. * For Set of keys use data.keySet(). */ // [START receive_message] @Override public void onMessageReceived(String from, Bundle data) { Log.d(TAG, data.toString()); String message = data.getString("message"); Log.d(TAG, "From: " + from); Log.d(TAG, "Message: " + message); if (from.startsWith("/topics/")) { // message received from some topic. } else { // normal downstream message. } // [START_EXCLUDE] /** * Production applications would usually process the message here. * Eg: - Syncing with server. * - Store message in local database. * - Update UI. */ //if(data.getString("collapse_key").equals(SystemPreferences.DATA_NOT_COLLAPSED)){ /** Respect order of inserting data into db!! * id * title * categories * description * address * price * image url * start time * end time **/ try { eventArr.add(data.getString("id")); } catch (MissingResourceException e) { e.printStackTrace(); eventArr.add("null"); } try { eventArr.add(data.getString("title")); } catch (MissingResourceException e) { e.printStackTrace(); eventArr.add("null"); } try { eventArr.add(data.getString("categories")); } catch (MissingResourceException e) { e.printStackTrace(); eventArr.add("null"); } try { eventArr.add(data.getString("description")); } catch (MissingResourceException e) { e.printStackTrace(); eventArr.add("null"); } try { eventArr.add(data.getString("address")); } catch (MissingResourceException e) { e.printStackTrace(); eventArr.add("null"); } try { eventArr.add(data.getString("price")); } catch (MissingResourceException e) { e.printStackTrace(); eventArr.add("null"); } try { eventArr.add(data.getString("image_url")); } catch (MissingResourceException e) { e.printStackTrace(); eventArr.add("null"); } try { eventArr.add(data.getString("start_timestamp")); } catch (MissingResourceException e) { e.printStackTrace(); eventArr.add("null"); } try { eventArr.add(data.getString("end_timestamp")); } catch (MissingResourceException e) { e.printStackTrace(); eventArr.add("null"); } Log.d(TAG, eventArr.toString()); // store into local db storeReceivedEvent(); //}else{ // Log.e(TAG, "data server pushed has collapsed"); //} // send refresh action to event listview activity Intent refreshIntent = new Intent(REFRESH_ACTION); sendBroadcast(refreshIntent); /** * In some cases it may be useful to show a notification indicating to the user * that a message was received. */ try { sendNotification(message, data.getString("title")); } catch (Exception e) { e.printStackTrace(); } // [END_EXCLUDE] }
From source file:org.sakaiproject.util.ResourceLoader.java
/** * Access some named property values as an array of strings. The name is the base name. name + ".count" must be defined to be a positive integer - how many are defined. name + "." + i (1..count) must be defined to be the values. * /*from w w w.j a v a 2s. c o m*/ * @param key * property key to look up in current ResourceBundle * @return The property value with this name, or the null if not found. * * @author Sugiura, Tatsuki (University of Nagoya) * @author Jean-Francois Leveque (Universite Pierre et Marie Curie - Paris 6) * */ public String[] getStrings(String key) { if (getLocale().toString().equals(DEBUG_LOCALE)) return new String[] { formatDebugPropertiesString(key) }; // get the count int count = getInt(key + ".count", 0); if (count > 0) { String[] rv = new String[count]; for (int i = 1; i <= count; i++) { String value = ""; try { value = getBundle().getString(key + "." + i); } catch (MissingResourceException e) { if (M_log.isWarnEnabled()) { M_log.warn("getStrings(" + key + ") swallowing MissingResourceException for String " + i); e.printStackTrace(); } // ignore the exception } rv[i - 1] = value; } return rv; } return null; }
From source file:eu.optimis.sm.gui.server.ServiceManagerWebServiceImpl.java
public ServiceManagerWebServiceImpl() { PropertyConfigurator.configure(ConfigManager.getFilePath(ConfigManager.LOG4J_CONFIG_FILE)); configServiceManagerWeb = ConfigManager.getPropertiesConfiguration(ConfigManager.SMWEB_CONFIG_FILE); logger.info("ServiceManagerWebServiceImpl initialisation started..."); try {//from www .ja v a2s . com ResourceBundle rb = ResourceBundle.getBundle("config", Locale.getDefault()); SM_URL = rb.getString("sm.url"); SM_PORT = rb.getString("sm.port"); SDO_URL = rb.getString("sdo.url"); IPS_URL = rb.getString("ips.url"); VPN_URL = rb.getString("vpn.url"); SEC_URL = rb.getString("sec.url"); TREC_URL = rb.getString("trec.url"); } catch (java.util.MissingResourceException e) { GWT.log("cannot found property file for SP Dashboard"); e.printStackTrace(); } catch (Exception ex) { GWT.log("cannot found property sm"); } hsqlServer = new Server(); hsqlServer.setLogWriter(null); hsqlServer.setSilent(true); hsqlServer.setDatabaseName(0, "xdb"); hsqlServer.setDatabasePath(0, "file:testdb"); if (session_ids.size() == 0) { session_ids.add("-1"); session_users.add("no_user"); session_times.add(0.0); } userKeyUnique = "1"; }
From source file:edu.ku.brc.specify.tasks.subpane.security.PrefsPermissionEnumerator.java
/** * Loads the Prefs and the Default Permissions from XML. *//*www . j a v a 2 s. c om*/ protected void loadPrefs() { prefOptions = new ArrayList<SecurityOptionIFace>(); try { Element root = XMLHelper.readDOMFromConfigDir("prefs_init.xml"); //$NON-NLS-1$ if (root != null) { Hashtable<String, Hashtable<String, PermissionOptionPersist>> mainHash = BaseTask .readDefaultPermsFromXML("prefsperms.xml"); Node prefsNode = root.selectSingleNode("/prefs"); String i18NResourceName = getAttr((Element) prefsNode, "i18nresname", (String) null); ResourceBundle resBundle = null; if (StringUtils.isNotEmpty(i18NResourceName)) { resBundle = UIRegistry.getResourceBundle(i18NResourceName); } List<?> sections = root.selectNodes("/prefs/section/pref"); //$NON-NLS-1$ for (Iterator<?> iter = sections.iterator(); iter.hasNext();) { org.dom4j.Element pref = (org.dom4j.Element) iter.next(); String name = getAttr(pref, "name", null); String title = getAttr(pref, "title", null); String iconName = getAttr(pref, "icon", null); if (StringUtils.isNotEmpty(name)) { if (resBundle != null) { try { title = resBundle.getString(title); } catch (MissingResourceException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance() .capture(PrefsPermissionEnumerator.class, ex); //log.error("Couldn't find key["+title+"]"); } } SecurityOption securityOption = new SecurityOption(name, title, "Prefs", iconName); prefOptions.add(securityOption); if (mainHash != null) { Hashtable<String, PermissionOptionPersist> hash = mainHash.get(name); if (hash != null) { for (PermissionOptionPersist pp : hash.values()) { PermissionIFace defPerm = pp.getDefaultPerms(); securityOption.addDefaultPerm(pp.getUserType(), defPerm); } } } } } } } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(PrefsPermissionEnumerator.class, ex); ex.printStackTrace(); } }
From source file:es.caib.seycon.ng.model.AuditoriaEntityDaoImpl.java
public void toAuditoriaCustom(es.caib.seycon.ng.model.AuditoriaEntity sourceEntity, es.caib.seycon.ng.comu.Auditoria targetVO) { targetVO.setAccount(sourceEntity.getAccount()); Date data = sourceEntity.getData(); if (data != null) { SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy kk:mm:ss"); //$NON-NLS-1$ targetVO.setData(dateFormat.format(data)); }//from w ww . ja v a2s . c o m targetVO.setCalendar(Calendar.getInstance()); targetVO.getCalendar().setTime(data); GrupEntity grup = sourceEntity.getGrup(); if (grup != null) { targetVO.setGrup(grup.getCodi()); } AccountEntity usuari = sourceEntity.getAccountAssoc(); if (usuari != null) { targetVO.setAutor(usuari.getName()); /* afegim nom complet de l'autor i el seu grup primari */ targetVO.setAutorNomComplet(usuari.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$ if (usuari.getType().equals(AccountType.USER)) { for (UserAccountEntity ua : usuari.getUsers()) { targetVO.setAutorGrupPrimari(ua.getUser().getGrupPrimari().getCodi()); } } } targetVO.setValorDomini(sourceEntity.getValorDomini()); if (sourceEntity.getFitxerId() != null) { // Atenci: els fitxers es poden esborrar... per aix no n'hi ha una // relaci amb els fitxers.. la que havia era amb el seu ID try { // FitxerEntity f = getFitxerEntityDao().findById(sourceEntity.getFitxerId()); // targetVO.setNomFitxer(f.getNom()); } catch (Throwable th) { //Marquem el seu id targetVO.setNomFitxer(sourceEntity.getFitxerId() + " (id)"); //$NON-NLS-1$ } targetVO.setFitxer(sourceEntity.getFitxerId()); } StringBuffer key = new StringBuffer(50); key.append(targetVO.getObjecte()).append('/').append(targetVO.getAccio()); try { String msg; try { msg = MessageFactory.getString(BUNDLE_NAME, key.toString()); } catch (MissingResourceException e) { msg = MessageFactory.getString(BUNDLE_NAME + "_" + targetVO.getObjecte(), targetVO.getAccio()); //$NON-NLS-1$ } StringBuffer result = new StringBuffer(); int processed = 0; do { int i = msg.indexOf("${", processed); //$NON-NLS-1$ if (i < 0) break; int j = msg.indexOf("}", i); //$NON-NLS-1$ if (j < 0) break; String variable = msg.substring(i + 2, j); result.append(msg.substring(processed, i)); processed = j + 1; try { Object property = BeanUtils.getProperty(targetVO, variable); if (property != null) result.append(property.toString()); } catch (Exception e) { logger.debug(String.format(Messages.getString("AuditoriaEntityDaoImpl.UnknownVariable"), //$NON-NLS-1$ variable, key)); result.append("${").append(variable).append("}"); //$NON-NLS-1$ //$NON-NLS-2$ } } while (true); result.append(msg.substring(processed)); targetVO.setMessage(result.toString()); } catch (Exception e) { e.printStackTrace(); targetVO.setMessage(String.format(Messages.getString("AuditoriaEntityDaoImpl.Action"), key)); //$NON-NLS-1$ } }