1
java.util.Schedule.next (알 수없는 소스), java.util.Scanner.throwFor에서 java.util.InputMismatchException 오류가 계속 발생합니다. java.util.Scanner.nextInt에서 .nextInt (알 수없는 소스) (알 수없는 소스)
파일 순서 : 나는 당신이 당신의 serialized
선수가 파일에 객체를 작성하는 ObjectOutputStream
를 사용해야합니다 생각Java : 레코드의 파일 배열을로드하는 중 문제가 발생했습니다.
import java.util.Scanner;
import java.io.*;
class PlayerStats
{
public String name;
public String team;
public int games_ply;
public int goals_mde;
}
public class Program3
{
public static void main(String[] args)
{
PlayerStats[] players = new PlayerStats[100];
int nPlayers;
int opt;
Scanner in = new Scanner (System.in
nPlayers = loadPlayers (players);
}
private static int loadPlayers (PlayerStats[] players)
{
int nPlayers = 0;
try
{
File file = new File ("/temp/Program3/Player.txt");
Scanner inFile = new Scanner (file);
do
{
players[ nPlayers ] = new PlayerStats();
players[ nPlayers ].name = inFile.next();
players[ nPlayers ].team = inFile.next();
players[ nPlayers ].games_ply = inFile.nextInt();
players[ nPlayers ].goals_mde = inFile.nextInt();
++nPlayers;
} while (players [nPlayers-1].goals_mde != 0);
--nPlayers;
}
catch (IOException ioe)
{
System.out.print("\n\n\t\tFile access error!");
nPlayers = 0;
}
return nPlayers;
}
}
그 int의 ne는 실제로는 int가 아닙니다. –
파일 내용을 제공 할 수 있습니까? – user2259824
파일 내용 - 문자열 문자열 int int - 예 : LebronJames MiamiaHeat 88 356 – user2810123