私のcsvはSystem.outに読み込まれていますが、スペースのあるテキストは次の行に移動されることに気づきました(戻り値として\ n)
csvの開始方法は次のとおりです。
first,last,email,address 1, address 2
john,smith,blah@blah.com,123 St. Street,
Jane,Smith,blech@blech.com,4455 Roger Cir,apt 2
アプリを実行した後、スペース(アドレス1)のあるセルはすべて次の行にスローされます。
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class main {
public static void main(String[] args) {
// -define .csv file in app
String fileNameDefined = "uploadedcsv/employees.csv";
// -File class needed to turn stringName to actual file
File file = new File(fileNameDefined);
try{
// -read from filePooped with Scanner class
Scanner inputStream = new Scanner(file);
// hashNext() loops line-by-line
while(inputStream.hasNext()){
//read single line, put in string
String data = inputStream.next();
System.out.println(data + "***");
}
// after loop, close scanner
inputStream.close();
}catch (FileNotFoundException e){
e.printStackTrace();
}
}
}
したがって、コンソールでの結果は次のとおりです。
最初、最後、メール、アドレス 1、住所 2 john、smith、blah @ blah.com、123 聖。 街、 Jane、Smith、blech @ blech.com、4455 ロジャー Cir、apt 2
スキャナーを間違って使用していますか?