JDK v1.7を使用して自分のPCで課題に取り組んでいますが、Javaバージョン1.6を搭載したUniのUnixコンピューターで課題を提出する必要があります。
私のコードはすべて私のマシンで正常に実行され、UniのコンピューターにSSHで接続してコードを転送すると、コンパイルも正常に行われます。しかし、私がそれを実行するために行くとき、私は受け取ります
NoSuchElementException: No line found
読み取る必要のある.xmlファイルに約1000〜1200文字(ファイルはこれよりはるかに長い)。
問題のある方法は
private CDAlbum CDread(Scanner inLine) {
String tempTitle = "Unknown CD";
String tempGenre = "Unknown Genre";
String tempArtist = "Unknown Artist";
ArrayList<String> tempTracks = new ArrayList<String>();
do {
lineBuffer = inLine.nextLine();
if (lineBuffer.equals("<Title>")) {
tempTitle = inLine.nextLine();
System.out.println("reading in a CD, just read title: " + tempTitle);
} else if (lineBuffer.equals("<Genre>")) {
tempGenre = inLine.nextLine();
} else if (lineBuffer.equals("<Artist>")) {
tempArtist = inLine.nextLine();
//System.out.println("Which has artist: " + tempArtist);
} else if (lineBuffer.equals("<Tracks>")) {
//populate tracks array
lineBuffer = inLine.nextLine();
while (!(lineBuffer.equals("</Tracks>"))) {
tempTracks.add(lineBuffer);
//System.out.println("Read track: " + lineBuffer);
lineBuffer = inLine.nextLine();
}
}
} while (!(lineBuffer.equals("</CD>")));
System.out.println(tempTracks);
CDAlbum tempdisc = new CDAlbum(tempTitle, tempGenre, tempArtist, tempTracks);
return tempdisc;
}
で発生するエラーで
lineBuffer = inLine.nextLine();
私はここでのデバッグの深さから少し外れています、そしてこれを引き起こしている可能性があるものについての提案は大歓迎です。
コンソール出力のスクリーンショット:http://puu.sh/YXKN
ソースコード全体(念のため、ドロップボックスで簡単に実行できるため):https ://www.dropbox.com/sh/zz8vdzqgw296s3d/v_cfW5svHG