帮助伙计们,我刚刚在网上看到了这个例子。我想用它来精确打印包含新行的相同格式的文本文件的内容,但它只打印出第一行。谢谢
import java.util.*;
import java.io.*;
public class Program
{
public static void main(String[] args)throws Exception
{
Scanner scanner = new Scanner(new FileReader("B:\\input.txt"));
String str = scanner.nextLine();
// Convert the above string to a char array.
char[] arr = str.toCharArray();
// Display the contents of the char array.
System.out.println(arr);
}
}