我想拆分字符串...我希望只吐出 5 次然后...休息 1 个字符串
我试过这个
public class FileRead
{
public static void main(String[] args) throws IOException
{
StringBuffer strBuff = new StringBuffer();
String str = null;
File file = new File("D:\\wokies\\5_dataset.txt");
try {
Scanner scanner = new Scanner(file);
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
System.out.println(line);
String [] splitSt =line.split(" ");
System.out.println("split happing");
for (int i = 0 ; i < splitSt.length ; i++)
{
System.out.println(splitSt[i]);
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}