public static void main(String ar[]) throws FileNotFoundException{
scan = new Scanner(new FileReader(new File("files.txt")));
String nextLine = scan.nextLine();
String[] fileNames = nextLine.split("\\s+");
for(int i=0;i<fileNames.length;i++){
System.out.println(fileNames[i]);
}
for(int i=0;i<nextLine.length();i++){
char c = nextLine.charAt(i);
boolean isWhiteSpace = isWhiteSpace(c);
if(isWhiteSpace){
if(c == ' ')
System.out.println("white space (blank) at index "+i);
if(c == '\n')
System.out.println("white space (line feed) at index "+i);
if(c == '\r')
System.out.println("white space (\\r - carriage return) at index "+i);
if(c == '\t')
System.out.println("white space (\\t - tab) at index "+i);
}
}
}
이 문제를 해결하는 데 도움이 필요합니다. 분명히 내 프로그램은 파일의 첫 번째 줄만 인식합니다.이 줄은 내용의 전체 파일을 읽어야합니다.전체 파일 대신 한 줄만 읽는 프로그램
변경하려면 어떤 변경이 필요합니까? 감사.
왜 전체 콘텐츠를 읽어야한다고 생각하십니까? –