0
我一直在使用JDK v1.7在我自己的PC上进行任务,我必须在我的uni Unix计算机上用java 1.6版提交我的任务。当1.7正常时,Java 1.6有读取文件时出现运行时错误
我的所有代码在我的机器上执行得很好,当我将SSH连入我的uni计算机并将代码转移到其他地方时,它也编译得很好。然而,当我去运行它,我收到一个
NoSuchElementException: No line found
约1000-1200字符到.xml文件我需要读取(该文件是比这更长的时间)。
违规的方法是
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();
错误我有点出我的调试深度的这里,并且任何建议,这可能是导致这是欢迎。控制台输出的
完整的源代码(以防万一,因为它很容易与Dropbox的做):不需要https://www.dropbox.com/sh/zz8vdzqgw296s3d/v_cfW5svHG