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


Java ResourceBundle.getBundle方法代码示例

本文整理汇总了Java中java.util.ResourceBundle.getBundle方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceBundle.getBundle方法的具体用法?Java ResourceBundle.getBundle怎么用?Java ResourceBundle.getBundle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.ResourceBundle的用法示例。


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

示例1: createActions

import java.util.ResourceBundle; //导入方法依赖的package包/类
@Override
protected void createActions() {
    super.createActions();
    ResourceBundle bundle = ResourceBundle.getBundle(Messages.getBundleName());
    ContentAssistAction action = new ContentAssistAction(bundle, "contentAssist.", this); //$NON-NLS-1$
    action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
    setAction(CONTENT_ASSIST, action);
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:9,代码来源:SQLEditor.java

示例2: getResourceBundle

import java.util.ResourceBundle; //导入方法依赖的package包/类
/** return the specified resource or null if not found */
public ResourceBundle getResourceBundle(String resource, Locale locale) {
    try {
        return ResourceBundle.getBundle(resource, locale);
    } catch (MissingResourceException e) {
        return null;
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:Bug4168625Class.java

示例3: getBundle

import java.util.ResourceBundle; //导入方法依赖的package包/类
private static ResourceBundle getBundle() {
    ResourceBundle bundle = com.intellij.reference.SoftReference.dereference(ourBundle);
    if (bundle == null) {
        bundle = ResourceBundle.getBundle(PATH_TO_BUNDLE);
        ourBundle = new SoftReference<>(bundle);
    }
    return bundle;
}
 
开发者ID:halirutan,项目名称:IntelliJ-Key-Promoter-X,代码行数:9,代码来源:KeyPromoterBundle.java

示例4: setResourceBundleAndKey

import java.util.ResourceBundle; //导入方法依赖的package包/类
private void setResourceBundleAndKey () {
    myLabel = ResourceBundle.getBundle("languages/labels", LocaleManager
            .getInstance().getCurrentLocaleProperty().get());
    myAngleKey = myLabel.getString("AngleKey");
    myWaitTimeKey = myLabel.getString("WaitTimeKey");
    myProjectileKey = myLabel.getString("ProjectileKey");
    myRangedKey = myLabel.getString("RangedKey");
    myRangeValueKey = myLabel.getString("RangeValueKey");
}
 
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:10,代码来源:DirectionalFireSFV.java

示例5: test

import java.util.ResourceBundle; //导入方法依赖的package包/类
private static void test(Locale locale) {
    Locale.setDefault(locale);
    ResourceBundle myResources =
            ResourceBundle.getBundle("Test4318520RB", Locale.FRENCH);
    String actualLocale = myResources.getString("name");
    if (!actualLocale.equals(locale.toString())) {
        System.out.println("expected: " + locale + ", got: " + actualLocale);
        throw new RuntimeException();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:11,代码来源:Test4318520.java

示例6: doGet

import java.util.ResourceBundle; //导入方法依赖的package包/类
@Override
public void doGet(HttpServletRequest request,
                  HttpServletResponse response)
    throws IOException, ServletException
{
    ResourceBundle rb =
        ResourceBundle.getBundle("LocalStrings",request.getLocale());
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();

    out.println("<html>");
    out.println("<head>");

    String title = rb.getString("helloworld.title");

    out.println("<title>" + title + "</title>");
    out.println("</head>");
    out.println("<body bgcolor=\"white\">");

    // note that all links are created to be relative. this
    // ensures that we can move the web application that this
    // servlet belongs to to a different place in the url
    // tree and not have any harmful side effects.

    // XXX
    // making these absolute till we work out the
    // addition of a PathInfo issue

    out.println("<a href=\"../helloworld.html\">");
    out.println("<img src=\"../images/code.gif\" height=24 " +
                "width=24 align=right border=0 alt=\"view code\"></a>");
    out.println("<a href=\"../index.html\">");
    out.println("<img src=\"../images/return.gif\" height=24 " +
                "width=24 align=right border=0 alt=\"return\"></a>");
    out.println("<h1>" + title + "</h1>");
    out.println("</body>");
    out.println("</html>");
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:39,代码来源:HelloWorldExample.java

示例7: main

import java.util.ResourceBundle; //导入方法依赖的package包/类
public static void main(String[] args) {
    try {
        ResourceBundle resource = ResourceBundle.getBundle(
                "resources.codepoint",
                Locale.getDefault());
        System.err.println(resource.getString("warning"));
    } catch (MissingResourceException e) {
        System.err.println(e.toString());
    }

    System.exit(1);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:CodePointIM.java

示例8: getProValue

import java.util.ResourceBundle; //导入方法依赖的package包/类
/**
 * 读取配置文件
 * 
 * @throws SysException
 */
public static String getProValue(String key) throws Exception {
	Locale locale = Locale.getDefault();
	ResourceBundle bundle;
	try {
		bundle = ResourceBundle.getBundle("config", locale);
	} catch (Exception e) {
		throw new Exception();
	}
	return bundle.getString(key);
}
 
开发者ID:LuJiangLin,项目名称:TestDemo1-github,代码行数:16,代码来源:Util.java

示例9: JSONObject

import java.util.ResourceBundle; //导入方法依赖的package包/类
/**
 * Construct a JSONObject from a ResourceBundle.
 * 
 * @param baseName The ResourceBundle base name.
 * @param locale The Locale to load the ResourceBundle for.
 * @throws JSONException If any JSONExceptions are detected.
 */
public JSONObject(String baseName, Locale locale) throws JSONException {
  this();
  ResourceBundle bundle =
      ResourceBundle.getBundle(baseName, locale, Thread.currentThread().getContextClassLoader());

  // Iterate through the keys in the bundle.

  Enumeration keys = bundle.getKeys();
  while (keys.hasMoreElements()) {
    Object key = keys.nextElement();
    if (key instanceof String) {

      // Go through the path, ensuring that there is a nested JSONObject for each
      // segment except the last. Add the value using the last segment's name into
      // the deepest nested JSONObject.

      String[] path = ((String) key).split("\\.");
      int last = path.length - 1;
      JSONObject target = this;
      for (int i = 0; i < last; i += 1) {
        String segment = path[i];
        JSONObject nextTarget = target.optJSONObject(segment);
        if (nextTarget == null) {
          nextTarget = new JSONObject();
          target.put(segment, nextTarget);
        }
        target = nextTarget;
      }
      target.put(path[last], bundle.getString((String) key));
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:40,代码来源:JSONObject.java

示例10: getResourceBundle

import java.util.ResourceBundle; //导入方法依赖的package包/类
public ResourceBundle getResourceBundle(Locale locale) {
    return ResourceBundle.getBundle(BUNDLE_NAME, locale);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:4,代码来源:UtilMessages.java

示例11: main

import java.util.ResourceBundle; //导入方法依赖的package包/类
public static void main (String ... args) {
    // Replace these with your client id and secret
    mySecrets = ResourceBundle.getBundle("facebookutil/secret");
    final String clientId = mySecrets.getString("googleId");
    final String clientSecret = mySecrets.getString("googleSecret");
    final OAuth20Service service = new ServiceBuilder()
            .apiKey(clientId)
            .apiSecret(clientSecret)
            .scope("https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.circles.write https://www.googleapis.com/auth/plus.circles.read https://www.googleapis.com/auth/plus.stream.write https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/plus.stream.read")
            .callback("https://github.com/duke-compsci308-spring2016/voogasalad_GitDepends")
            .build(GoogleApi20.instance());
    Scanner in = new Scanner(System.in, "UTF-8");

    System.out.println("=== " + NETWORK_NAME + "'s OAuth Workflow ===");
    System.out.println();

    // Obtain the Authorization URL
    System.out.println("Fetching the Authorization URL...");

    final Map<String, String> additionalParams = new HashMap<>();
    additionalParams.put("access_type", "offline");
    // force to retrieve refresh token (if users are asked not the first time)
    additionalParams.put("prompt", "consent");
    final String authorizationUrl = service.getAuthorizationUrl(additionalParams);
    System.out.println("Got the Authorization URL!");
    System.out.println("Now go and authorize ScribeJava here:");
    System.out.println(authorizationUrl);
    System.out.println("And paste the authorization code here");
    System.out.print(">>");
    final String code = in.nextLine();
    System.out.println();

    System.out.println("Trading the Request Token for an Access Token...");
    OAuth2AccessToken accessToken = service.getAccessToken(code);
    System.out.println("Got the Access Token!");
    System.out.println("(if your curious it looks like this: " + accessToken +
                       ", 'rawResponse'='" + accessToken.getRawResponse() + "')");

    System.out.println("Refreshing the Access Token...");
    accessToken = service.refreshAccessToken(accessToken.getRefreshToken());
    System.out.println("Refreshed the Access Token!");
    System.out.println("(if your curious it looks like this: " + accessToken +
                       ", 'rawResponse'='" + accessToken.getRawResponse() + "')");
    System.out.println();

    // Now let's go and ask for a protected resource!
    System.out.println("Now we're going to access a protected resource...");
    while (true) {
        System.out
                .println("Paste fieldnames to fetch (leave empty to get profile, 'exit' to stop example)");
        System.out.print(">>");
        final String query = in.nextLine();
        System.out.println();

        final String requestUrl;
        if ("exit".equals(query)) {
            break;
        }
        else if (query == null || query.isEmpty()) {
            requestUrl = PROTECTED_RESOURCE_URL;
        }
        else {
            requestUrl = PROTECTED_RESOURCE_URL + "?fields=" + query;
        }

        final OAuthRequest request = new OAuthRequest(Verb.GET, requestUrl, service);
        service.signRequest(accessToken, request);
        final Response response = request.send();
        System.out.println();
        System.out.println(response.getCode());
        System.out.println(response.getBody());

        System.out.println();
    }
    in.close();
}
 
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:77,代码来源:GooglePlusExample.java

示例12: MessageBundle

import java.util.ResourceBundle; //导入方法依赖的package包/类
public MessageBundle(String languageTag) {
    Locale locale = languageTag != null ? new Locale(languageTag) : Locale.ENGLISH;
    this.messages = ResourceBundle.getBundle("localization/messages", locale);
}
 
开发者ID:tipsy,项目名称:javalin-website-example,代码行数:5,代码来源:MessageBundle.java

示例13: main

import java.util.ResourceBundle; //导入方法依赖的package包/类
public static void main(String... args) {
    List<String> errors = new ArrayList<>();
    // Ensure that all Message fields have a corresponding key/value
    // in the resource bundle and that mnemonics can be looked
    // up where applicable.
    ResourceBundle rb = ResourceBundle.getBundle(RESOURCE_BUNDLE);
    for (Field field : Messages.class.getFields()) {
        if (isResourceKeyField(field)) {
            String resourceKey = field.getName();
            String message = readField(field);
            if (message.startsWith(MISSING_RESOURCE_KEY_PREFIX)) {
                errors.add("Can't find message (and perhaps mnemonic) for "
                        + Messages.class.getSimpleName() + "."
                        + resourceKey + " in resource bundle.");
            } else {
                String resourceMessage = rb.getString(resourceKey);
                if (hasMnemonicIdentifier(resourceMessage)) {
                    int mi = Resources.getMnemonicInt(message);
                    if (mi == 0) {
                        errors.add("Could not look up mnemonic for message '"
                                + message + "'.");
                    }
                }
            }
        }
    }

    // Ensure that there is Message class field for every resource key.
    for (String key : Collections.list(rb.getKeys())) {
        try {
            Messages.class.getField(key);
        } catch (NoSuchFieldException nfe) {
            errors.add("Can't find static field ("
                    + Messages.class.getSimpleName() + "." + key
                    + ") matching '" + key
                    + "' in resource bundle. Unused message?");
        }
    }

    if (errors.size() > 0) {
        throwError(errors);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:44,代码来源:ResourceCheckTest.java

示例14: main

import java.util.ResourceBundle; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    if (args.length != 2) {
        System.out.println("Usage: java ... basename should-be-loaded-flag");
        System.out.println("  ex. java ... jdk.test.resources.classes.MyResources false");
        return;
    }

    String basename = args[0];
    boolean shouldBeLoaded = "true".equals(args[1]);

    int errors = 0;

    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    if (cl == null) {
        cl = ClassLoader.getSystemClassLoader();
    }

    try {
        // Set the default Locale to Locale.ROOT to avoid any confusions related to fallback
        Locale.setDefault(Locale.ROOT);
        ResourceBundle rb = ResourceBundle.getBundle(basename,
                                                     cl.getUnnamedModule());
        if (shouldBeLoaded) {
            System.out.println("Passed: got resource bundle:");
        } else {
            System.out.println("Failed: no MissingResourceException thrown");
            errors++;
        }
        System.out.println("            bundle = " + rb);
    } catch (MissingResourceException e) {
        if (!shouldBeLoaded) {
            System.out.println("Passed: got expected " + e);
        } else {
            System.out.println("Failed: got unexpected " + e);
            errors++;
        }
        System.out.println("            cause = " + e.getCause());
    } catch (Throwable t) {
        System.out.println("Failed: unexpected throwable: " + t);
        errors++;
    }

    if (errors > 0) {
        throw new RuntimeException(errors + " errors");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:47,代码来源:TestWithUnnamedModuleArg.java

示例15: getMessage

import java.util.ResourceBundle; //导入方法依赖的package包/类
/**
 * Produces exception message from resource bundle.
 *
 * @param key  message key
 * @param args message additional arguments
 *
 * @return formatted localized string
 */
public static String getMessage (String key, Object... args) {
    val bundle = ResourceBundle.getBundle("localization/exception", new UTF8Control());
    val messagePattern = bundle.getString(key);
    return MessageFormatter
            .arrayFormat(messagePattern, args)
            .getMessage();
}
 
开发者ID:xxlabaza,项目名称:ping,代码行数:16,代码来源:I18nExceptionUtil.java


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