2016-11-07 7 views
0

私はテキストファイルから文字を読むのに助けが必要です。 私は文字で文字を読み、ecpaceここ文字で文字ファイルを読む

のIDを取得したいが、私のコードです:

public class GenieL { 
    String Nom_of_TACHE; 
    int ID ; 
    int time; 
    Array table[]; 
    public static void main(String[] args) throws IOException { 
     BufferedReader br=null; 
     String strLine=""; 

     try { 
      br=new BufferedReader (new FileReader("my.txt")); 

      while((strLine=br.readLine())!=null){ 
       System.out.println(strLine); 
       Nom_of_TACHE=parseint(strLine);// 
      } 
     } catch (FileNotFoundException ex) { 
      System.err.println("Unable to find the file name "); 
     } 
     catch (IOException e) { 
      System.err.println("Unable to read find the file name "); 
     } 
}} 
+0

は、行毎にファイルを読み込むと、すべての行が文字列であることから、その上の文字でforループをしてください... –

+0

どのようにそれを行う! –

+0

「私のためのコードを書く」ですか? – olyv

答えて

1

行毎にファイルを読み、すべての行が文字列であることから、その上に文字を持つforループを行う...

public static void main(String[] args) { 
try { 
    BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("./Details.txt"), "UTF8")); 

    String line; 
    while ((line = br.readLine()) != null) { 
    for (int i = 0; i < line.length(); i++) { 
     System.out.println("Char at: " + line.charAt(i)); 
    } 
    System.out.println("Another line"); 
    } 
    br.close(); 

} catch (IOException e) { 
    e.printStackTrace(); 
} 
} 
+0

それはあなたを感謝しています –