.txt ファイルをアップロードしたときに次の行を読み取れない理由を教えてください。アップロードしようとするすべての .txt ファイルに発生し、次に system.out.println() を使用します。私のテキストファイルには、猫、犬、猿(それぞれ1行)が含まれています..しかし、出力される値は次のとおりです。
[Monkey][Monkey, null][Monkey, null, null][Monkey, null, null, null][Monkey, null, null, null, null][Monkey, null, null, null, null, null][Monkey, null, null, null, null, null, null]
これについて助けが必要です。ありがとうございました。
なぜ私は.docではなく.txtファイルを読むことができるのか疑問に思っています. これについてもアドバイスが必要です。
import java.awt.List;
import java.io.*;
import java.util.ArrayList;
import javax.imageio.IIOException;
import javax.swing.JFileChooser;
public class searchforCapitalLetter {
public static void main(String[] args) throws IOException{
try {
// file chooser
JFileChooser chooser=new JFileChooser();
int returnVal = chooser.showOpenDialog(null);{
if(returnVal == JFileChooser.APPROVE_OPTION)
{ File f = chooser.getSelectedFile();}
FileInputStream fin = new FileInputStream(chooser.getSelectedFile());
DataInputStream din = new DataInputStream(fin);
BufferedReader br = new BufferedReader(new InputStreamReader(din));
ArrayList<String>list =new ArrayList<String> ();
if ((br.readLine()) != null) {
while (br.readLine() != " ") {
list.add(br.readLine());
System.out.print (list);
} br.close() ;
}//closes if statement
} // closes method dialog
} // closes try method
catch (FileNotFoundException e) {
e.printStackTrace();
} // closes catch method
} // closes method body
} // closes class method