Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Encoding 如何使用Java读取希腊文属性文件_Encoding - Fatal编程技术网

Encoding 如何使用Java读取希腊文属性文件

Encoding 如何使用Java读取希腊文属性文件,encoding,Encoding,我正在尝试读取一个属性文件,该文件的键为英语,值为希腊语。我的代码如下: public class I18NSample { static public void main(String[] args) { String language; String country; if (args.length != 2) { language = new String("el"); country = new St

我正在尝试读取一个属性文件,该文件的键为英语,值为希腊语。我的代码如下:

public class I18NSample {

   static public void main(String[] args) {

      String language;
      String country;

      if (args.length != 2) {
          language = new String("el");
          country = new String("GR");
      } else {
          language = new String(args[0]);
          country = new String(args[1]);
      }

      Locale currentLocale;
      ResourceBundle messages;

      currentLocale = new Locale(language, country);

      messages =
        ResourceBundle.getBundle("MessagesBundle",currentLocale, new CustomClassLoader("E:\\properties"));

      System.out.println(messages.getString("greetings"));
      System.out.println(messages.getString("inquiry"));
      System.out.println(messages.getString("farewell"));
   }
}


MessagesBundle_el_GR.properties 问候语=ρήμ。χαιρετώ 再见=επφ。αντίο

查询=τικάνεσ,τικάνετε 我像这样编译javac编码的UTF8 CustomClassLoader.java javac-编码UTF8 I18Sample.java

当我运行这个程序时,我得到的输出是乱码。如果properies文件是英文、法文或德文的,它就可以正常工作。 请帮忙。 当做 subheadu

根据,属性文件似乎仅限于ISO 8859-1。然而,它们确实支持Unicode转义,并且链接的文档有一个自动生成所述转义的工具

XML加载器允许UTF-8编码的XML

javac
选项仅适用于
.java
文件中的字符串文本,对程序的运行时行为不起任何作用。

谢谢大家

我尝试直接从属性文件中读取,如下所示:

FileInputStream fis = new FileInputStream("E:\\properties\\MessagesBundle_el_GR.properties");
        DataInputStream dis = new DataInputStream(fis);
        BufferedReader br = new BufferedReader(new InputStreamReader(dis, "ISO-8859-7"));
        String strLine;
        while((strLine = br.readLine()) != null){
            System.out.println(strLine);
        }

        dis.close();
这没有帮助

我们可以将相同的信息放在数据库中并从那里读取。虽然在安装mysql数据库的机器终端中,当我们试图从java代码中读取相同的信息时,会正确地以希腊语显示该信息,但它会变得乱码。javac编码UTF8是否有助于从数据库中读取该信息

native2ascii工具不会有多大帮助,因为我们系统的用户不会同意承担所有这些痛苦。用户已经准备好使用数据库(因为我们将提供一个GUI以进入数据库)或属性文件

问候,



subheadu

可能尝试打印到console是个坏主意,因为console无法打印除latin1之外的任何内容。我将尝试将输出打印到文件----苏本杜
FileInputStream fis = new FileInputStream("E:\\properties\\MessagesBundle_el_GR.properties");
        DataInputStream dis = new DataInputStream(fis);
        BufferedReader br = new BufferedReader(new InputStreamReader(dis, "ISO-8859-7"));
        String strLine;
        while((strLine = br.readLine()) != null){
            System.out.println(strLine);
        }

        dis.close();