2013-04-01 30 views
-1

我目前在讀一文件到Java該文件包含(「字符符號」「標籤」,「6逗號分隔布爾」,「新線」)在英鎊符號和語音標記閱讀

我的列表仔細閱讀並將其分開即可 - 但是我遇到了一個問題,即英鎊符號和語音標記正在作爲帶有問號的黑色鑽石讀入。這是搞砸了一切,因爲我需要能夠確定哪些代碼與哪個字符符號。

我讀使用:

public void read() 
{ 

    int i = 0; 
    try{ 
    // Open the file 
    InputStream is = am.open("combinations.txt"); 
    // Get the object of DataInputStream 
    DataInputStream in = new DataInputStream(is); 
    BufferedReader br = new BufferedReader(new InputStreamReader(in)); 
    String strLine; 
    //Read File Line By Line 
    while ((strLine = br.readLine()) != null && i < 53) { 
    String[] sep1 = strLine.split("\t"); 
    String[] sep2 = sep1[1].split(","); 
    entries[i] = new Entry(sep1[0].charAt(0), new CellPattern(Boolean.valueOf(sep2[0]), 
     Boolean.valueOf(sep2[1]),Boolean.valueOf(sep2[2]),Boolean.valueOf(sep2[3]), 
     Boolean.valueOf(sep2[4]),Boolean.valueOf(sep2[5]))); 
    i++; 
    } 
    //Close the input stream 
    in.close(); 
    }catch (Exception e){//Catch exception if any 
    System.err.println("Error: " + e.getMessage()); 
    } 
+0

您可以提供從您所在的地區問題讀取文件採樣線?你如何顯示角色? charAt(0)應該返回一個#符號就好了...... –

+0

請不要使用DataInputStream來讀取文本文件。你不需要它,所以請刪除它,因爲人們可能會複製此代碼。 –

回答

2

這是一個編碼的問題,請嘗試更改您的BufferedReader行:

BufferedReader br = new BufferedReader(new InputStreamReader(in, "UTF-8")); 

我不知道它的編碼,你需要,所以你可能想嘗試一些不同的。

編輯: 嘗試「ISO-8859-1」