当前位置: 首页>>代码示例>>Java>>正文


Java PropertyResourceBundle类代码示例

本文整理汇总了Java中java.util.PropertyResourceBundle的典型用法代码示例。如果您正苦于以下问题:Java PropertyResourceBundle类的具体用法?Java PropertyResourceBundle怎么用?Java PropertyResourceBundle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PropertyResourceBundle类属于java.util包,在下文中一共展示了PropertyResourceBundle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: DBManager

import java.util.PropertyResourceBundle; //导入依赖的package包/类
public DBManager() {
 ResourceBundle rb = PropertyResourceBundle.getBundle(
    "com.gint.app.bisisadmin.Config");
 String driver     = rb.getString("driver");
 String URL        = rb.getString("url");
 String username   = rb.getString("username");
 String password   = rb.getString("password");
	
 try {
   Class.forName(driver);
   GenericObjectPool connectionPool = new GenericObjectPool(null);
   DriverManagerConnectionFactory connectionFactory = 
     new DriverManagerConnectionFactory(URL, username, password);
   PoolableConnectionFactory poolableConnectionFactory =
     new PoolableConnectionFactory(connectionFactory, connectionPool, null, 
         null, false, false);
   poolingDataSource = new PoolingDataSource(connectionPool);
 } catch (Exception ex) {
   ex.printStackTrace();
 }  
}
 
开发者ID:unsftn,项目名称:bisis-v4,代码行数:22,代码来源:DBManager.java

示例2: addData

import java.util.PropertyResourceBundle; //导入依赖的package包/类
private void addData(FileOutputStream fos, PropertyResourceBundle bundle, PropertyResourceBundle backupBundle, String localeName, List <String> propertiesNames) throws IOException {
    String propertyName;
    String localizedString;
    addData(fos, localeName, true);
    Enumeration <String> en = bundle.getKeys();
    for(int i=0;i<propertiesNames.size();i++) {
        String str = null;
        try {
            str = bundle.getString(propertiesNames.get(i));
        } catch (MissingResourceException e) {
            if(backupBundle!=null) {
                str = backupBundle.getString(propertiesNames.get(i));
            }
        }
        str = changeJavaPropertyCounter(str);
        addData(fos, str, true); // localized string as UNICODE
        
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ExeLauncher.java

示例3: getRef

import java.util.PropertyResourceBundle; //导入依赖的package包/类
/**
 * Return a ref to a new or existing RefCapablePropertyResourceBundle,
 * or throw a MissingResourceException.
 */
static private RefCapablePropertyResourceBundle getRef(String baseName,
        ResourceBundle rb, ClassLoader loader) {
    if (!(rb instanceof PropertyResourceBundle))
        throw new MissingResourceException(
                "Found a Resource Bundle, but it is a "
                        + rb.getClass().getName(),
                PropertyResourceBundle.class.getName(), null);
    if (allBundles.containsKey(rb))
        return (RefCapablePropertyResourceBundle) allBundles.get(rb);
    RefCapablePropertyResourceBundle newPRAFP =
            new RefCapablePropertyResourceBundle(baseName,
                    (PropertyResourceBundle) rb, loader);
    allBundles.put(rb, newPRAFP);
    return newPRAFP;
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:20,代码来源:RefCapablePropertyResourceBundle.java

示例4: getResourceBundle

import java.util.PropertyResourceBundle; //导入依赖的package包/类
/**
 * Gets a resource bundle using the specified base name and locale, and the caller's class loader.
 * @param bundle the base name of the resource bundle, a fully qualified class name
 * @param locale the locale for which a resource bundle is desired
 * @return a resource bundle for the given base name and locale
 */
public static ResourceBundle getResourceBundle(final String bundle, final Locale locale) {
    return AccessController.doPrivileged(new PrivilegedAction<ResourceBundle>() {
        public ResourceBundle run() {
            try {
                return PropertyResourceBundle.getBundle(bundle, locale);
            } catch (MissingResourceException e) {
                try {
                    return PropertyResourceBundle.getBundle(bundle, new Locale("en", "US"));
                } catch (MissingResourceException e2) {
                    throw new MissingResourceException(
                            "Could not load any resource bundle by " + bundle, bundle, "");
                }
            }
        }
    });
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:SecuritySupport.java

示例5: Bug6204853

import java.util.PropertyResourceBundle; //导入依赖的package包/类
public Bug6204853() {
    String srcDir = System.getProperty("test.src", ".");
    try (FileInputStream fis8859_1 =
             new FileInputStream(new File(srcDir, "Bug6204853.properties"));
         FileInputStream fisUtf8 =
             new FileInputStream(new File(srcDir, "Bug6204853_Utf8.properties"));
         InputStreamReader isrUtf8 = new InputStreamReader(fisUtf8, "UTF-8"))
    {
        PropertyResourceBundle bundleUtf8 = new PropertyResourceBundle(isrUtf8);
        PropertyResourceBundle bundle = new PropertyResourceBundle(fis8859_1);

        String[] arrayUtf8 = createKeyValueArray(bundleUtf8);
        String[] array = createKeyValueArray(bundle);

        if (!Arrays.equals(arrayUtf8, array)) {
            throw new RuntimeException("PropertyResourceBundle constructed from a UTF-8 encoded property file is not equal to the one constructed from ISO-8859-1 encoded property file.");
        }
    } catch (FileNotFoundException fnfe) {
        throw new RuntimeException(fnfe);
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:24,代码来源:Bug6204853.java

示例6: createKeyValueArray

import java.util.PropertyResourceBundle; //导入依赖的package包/类
private final String[] createKeyValueArray(PropertyResourceBundle b) {
    List<String> keyValueList = new ArrayList<String>();
    StringBuilder sb = new StringBuilder();

    for (String key : b.keySet()) {
        sb.setLength(0);
        sb.append(key);
        sb.append(" = ");
        sb.append(b.getString(key));
        keyValueList.add(sb.toString());
    }

    String[] keyValueArray = keyValueList.toArray(new String[0]);
    Arrays.sort(keyValueArray);
    return keyValueArray;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:17,代码来源:Bug6204853.java

示例7: initLabels

import java.util.PropertyResourceBundle; //导入依赖的package包/类
public static void initLabels() {
	// custom bundle to be able to read the UTF-8 Japanese property file
	String name = "Labels";
	if (Env.INSTANCE.getAppliLanguage() != null) {
		switch (Env.INSTANCE.getAppliLanguage()) {
		case JAPANESE:
			name += "_ja_JP";
			break;
		case FRENCH:
			name += "_fr_FR";
			break;
		case GERMAN:
			name += "_de_DE";
			break;
		default:
			break;
		}
	}
	name += ".properties";
	final InputStream stream = Resources.class.getResourceAsStream(name);
	try {
		LABEL_BUNDLE = new PropertyResourceBundle(new InputStreamReader(stream, "UTF-8"));
	} catch (final Exception e) {
		LOGGER.error("Failed to load resource bundle", e);
	}
}
 
开发者ID:leolewis,项目名称:openvisualtraceroute,代码行数:27,代码来源:Resources.java

示例8: newBundle

import java.util.PropertyResourceBundle; //导入依赖的package包/类
public static PropertyResourceBundle newBundle(java.io.File propertiesFile) throws IOException {
	InputStream stream = new FileInputStream(propertiesFile);
	try {
		// stream = new FileInputStream(propertiesFile);
		return new PropertyResourceBundle(new InputStreamReader(stream, ENCODING));
		// } catch (IOException e) {
		// // e.printStackTrace();
	} finally {
		// try {
		stream.close();
		// } catch (IOException e) {
		// }
		// if (stream != null) {
		// stream.close();
		// }
	}
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:18,代码来源:BundleControl.java

示例9: VirtualChestTranslation

import java.util.PropertyResourceBundle; //导入依赖的package包/类
public VirtualChestTranslation(VirtualChestPlugin plugin)
{
    Locale locale = Locale.getDefault();
    AssetManager assets = Sponge.getAssetManager();
    logger = plugin.getLogger();
    try
    {
        Asset asset = assets.getAsset(plugin, "i18n/" + locale.toString() + ".properties").orElse(assets.
                getAsset(plugin, "i18n/en_US.properties").orElseThrow(() -> new IOException(I18N_ERROR)));
        resourceBundle = new PropertyResourceBundle(new InputStreamReader(asset.getUrl().openStream(), Charsets.UTF_8));
    }
    catch (IOException e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:ustc-zzzz,项目名称:VirtualChest,代码行数:17,代码来源:VirtualChestTranslation.java

示例10: newBundle

import java.util.PropertyResourceBundle; //导入依赖的package包/类
@Override
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload)
    throws IllegalAccessException, InstantiationException, IOException {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("New bundle: {}, locale {}", baseName, locale);
    }
    if (locale.equals(Locale.ROOT)) {
        //MCR-1064 fallback should be default language, if property key does not exist
        locale = defaultLocale;
    }
    String bundleName = baseName.substring(baseName.indexOf(':') + 1);
    String filename = CONTROL_HELPER.toBundleName(bundleName, locale) + ".properties";
    try (MCRConfigurationInputStream propertyStream = new MCRConfigurationInputStream(filename)) {
        if (propertyStream.isEmpty()) {
            throw new MissingResourceException(
                "Can't find bundle for base name " + baseName + ", locale " + locale, bundleName + "_" + locale, // className
                "");
        }
        return new PropertyResourceBundle(propertyStream);
    }
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:22,代码来源:MCRCombinedResourceBundleControl.java

示例11: JmolResourceHandler

import java.util.PropertyResourceBundle; //导入依赖的package包/类
private JmolResourceHandler() {
    String language = "en";
    String country = "";
    String localeString = GT.getLanguage();
//    String localeString = System.getProperty("user.language");
    if (localeString != null) {
      StringTokenizer st = new StringTokenizer(localeString, "_");
      if (st.hasMoreTokens()) {
        language = st.nextToken();
      }
      if (st.hasMoreTokens()) {
        country = st.nextToken();
      }
    }
    Locale locale = new Locale(language, country);
    stringsResourceBundle =
      ResourceBundle.getBundle("org.openscience.jmol.app.jmolpanel.Properties.Jmol", locale);

    try {
      String t = "/org/openscience/jmol/app/jmolpanel/Properties/Jmol-resources.properties";
      generalResourceBundle =
        new PropertyResourceBundle(getClass().getResourceAsStream(t));
    } catch (IOException ex) {
      throw new RuntimeException(ex.toString());
    }
  }
 
开发者ID:mleoking,项目名称:PhET,代码行数:27,代码来源:JmolResourceHandler.java

示例12: newBundle

import java.util.PropertyResourceBundle; //导入依赖的package包/类
@Override
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload)
        throws IllegalAccessException, InstantiationException, IOException {

    String bundleName = toBundleName(baseName, locale);
    String resourceName = toResourceName(bundleName, "properties");
    final URL resourceURL = loader.getResource(resourceName);
    if (resourceURL == null)
        return null;

    BufferedReader in = new BufferedReader(new InputStreamReader(resourceURL.openStream(), StandardCharsets.UTF_8));

    try {
        return new PropertyResourceBundle(in);
    } finally {
        in.close();
    }
}
 
开发者ID:viydaag,项目名称:dungeonstory-java,代码行数:19,代码来源:Messages.java

示例13: method6

import java.util.PropertyResourceBundle; //导入依赖的package包/类
void method6() throws Exception {
    String srcDir = System.getProperty("test.src", ".");
    try (FileInputStream fis8859_1 = new FileInputStream(new File(srcDir, "Bug6204853.properties"));
         FileInputStream fisUTF8 = new FileInputStream(new File(srcDir, "Bug6204853_Utf8.properties"));
         InputStreamReader isrutf8 = new InputStreamReader(fisUTF8, "UTF-8")) {
        PropertyResourceBundle bundleUtf8 = new PropertyResourceBundle(isrutf8);
        PropertyResourceBundle bundle = new PropertyResourceBundle(fis8859_1);
        String[] arrayUtf8 = {"1", "2", "3"};
        String[] array = {"key1", "key2"};
        if (!Arrays.equals(arrayUtf8, array)) {
            throw new RuntimeException("Error message");
        }
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:17,代码来源:InputLocalFinalVariableNameTryResources.java

示例14: getString

import java.util.PropertyResourceBundle; //导入依赖的package包/类
@Override
public String getString(String key) {
	try {
		String localeProp = configurationService.getLiderLocale();
		if (localeProp != null && !localeProp.equalsIgnoreCase(lastLocaleProp)) {
			PropertyResourceBundle.clearCache();
			lastLocaleProp = localeProp;
		}
		Locale targetLocale = localeProp.contains("-") || localeProp.contains("_")
				? Locale.forLanguageTag(localeProp) : new Locale(localeProp);
		ResourceBundle resourceBundle = PropertyResourceBundle.getBundle(BUNDLE_NAME, targetLocale);
		return resourceBundle.getString(key);
	} catch (Exception e) {
		logger.error(e.getMessage(), e);
		return '!' + key + '!';
	}
}
 
开发者ID:Pardus-LiderAhenk,项目名称:lider,代码行数:18,代码来源:LocaleServiceImpl.java

示例15: startUp

import java.util.PropertyResourceBundle; //导入依赖的package包/类
/**
 * Provides an <CODE>Application</CODE> with a chance to perform any
 * initialisation. This implementation checks for the -help option.
 * Derived classes may extend the functionality.
 * @since	TFP 1.0
 */
protected void startUp ()
{
	if (helpOption.isPresent ()) {
		System.err.println ("Usage:\n    java " + this.getClass ().getName ()
				+ Option.listOptions () + describeArguments ());
		System.err.println ();
		System.err.println ("Options:");
		Option.describeOptions ();
		System.exit (1);
	}
	
	// Load settings bundle if defined.
	try {
		settings = PropertyResourceBundle.getBundle (getClass ().getName ());
	}
	catch (MissingResourceException error) {
		settings = null;
	}
}
 
开发者ID:handcoded,项目名称:fpml-toolkit-java,代码行数:26,代码来源:Application.java


注:本文中的java.util.PropertyResourceBundle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。