How to load a resource bundle from a file resource in Java?

前端 未结 14 851
没有蜡笔的小新
没有蜡笔的小新 2020-11-28 08:19

I have a file called mybundle.txt in c:/temp -

c:/temp/mybundle.txt

How do I load this file into a java.util.Res

14条回答
  •  感情败类
    2020-11-28 09:11

    When you say it's "a valid resource bundle" - is it a property resource bundle? If so, the simplest way of loading it probably:

    try (FileInputStream fis = new FileInputStream("c:/temp/mybundle.txt")) {
      return new PropertyResourceBundle(fis);
    }
    

提交回复
热议问题