txt 파일에서 오는 이름 목록을 사용하여 문자열 배열을 만들려고합니다. 예 : string [] names = {txtfile의 모든 이름 (하나의 이름 인라인)} "names"와 같은 배열을 사용하는 메서드에 "names"를 전달하려고합니다. 위에 만든). 이 메서드는 다른 for 루프를 통해 이름을 실행하고 연결된 목록을 만듭니다. 나는 이것에 자신을 혼란스럽게하고 많은 것들을 시도했지만 아무것도 작동하지 않는 것 같다. 지금 당장은 이름을 올바르게 출력 할 것이지만 그 이후의 모든 이름은 null로 표시됩니다. 그래서 약 70 널이 인쇄되고있다.여러 줄의 줄을 사용하여 txt 파일을 읽는 방법
public static void main(String[] args) {
//String[] names = {"Billy Joe", "Alan Bowe", "Sally Mae", "Joe Blow", "Tasha Blue", "Malcom Floyd"}; // Trying to print theses names..Possibly in alphabetical order
BigNode x = new BigNode();
Scanner in = new Scanner(System.in);
System.out.println("Enter File Name: ");
String Finame = in.nextLine();
System.out.println("You Entered " + Finame);
try {File file = new File(Finame);
BufferedReader readers = new BufferedReader(new FileReader(file));
// String nameLine = ;
String[] name;
name = new String[73];
String[] nameTO;
String nameLine;
// while ((nameLine = readers.readLine()) != null) {
for (int i = 0; i < name.length; i++){
name[i] = readers.readLine();
x.populateNodes(name);
} //}
} catch(IOException e) {
}
숙제 인 경우 숙제 태그를 추가하십시오. –