操纵阿拉伯文本文件Java

时间:2018-03-30 12:49:05

标签: java file-io arabic

我正在尝试使用IntelliJ读取阿拉伯语文本文件,虽然没有错误,但输出不可读。在阿拉伯语中尝试简单的输出语句。 这是我的代码:

public static void main(String[] args) {
    //The name of the file to open.
    String fileName = "myFile.txt";

    // This will reference one line at a time
    String line = null;

    System.out.println("أهلا يا عالم");

    try {
        // FileReader reads text files in the default encoding.
        Reader fileReader =
                new InputStreamReader(new FileInputStream("myFile.txt"), "utf-8");

        // Always wrap FileReader in BufferedReader.
        BufferedReader bufferedReader =
                new BufferedReader(fileReader);

        while((line = bufferedReader.readLine()) != null) {
            System.out.println(line);}
     }
}

这是我的一些输出:

    أهلا يا عالم
{\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf200
{\fonttbl\f0\froman\fcharset0 TimesNewRomanPSMT;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}\paperw11900\paperh16840\margl1440\margr1440\vieww10980\viewh8400\viewkind0
\deftab720\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\tx10171\pardeftab720\qr\partightenfactor0\f0\fs24\cf0 1\\uc0\u1576 \u1587 \u1605  \u1575 \u1604 \u1604 \u1607  \u1575 \u1604 \u1585 \u1581 \u1605 \u1606  \u1575 \u1604 \u1585 \u1581 \u1610 \u1605  \u1575 \u1604 \u1581 \u1605

这些是myFile的一些行:

1 بسماللهالرحمنالرحيمالحمدللهربالعالمينالرحمنالرحيممالكيومالدين

2 وصلىاللهوسلمعلىالنبيالمصطفىوآلهوصحبهومناقتفى

谢谢,

0 个答案:

没有答案