2013-09-24 3 views
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; 
    } 
} 
+0

그 int의 ne는 실제로는 int가 아닙니다. –

+0

파일 내용을 제공 할 수 있습니까? – user2259824

+0

파일 내용 - 문자열 문자열 int int - 예 : LebronJames MiamiaHeat 88 356 – user2810123

답변

0

INT INT 문자열 문자열 그리고 물체를 읽으려면 ObjectInputStream(new FileInputStream(new File(players.txt))).readObject을 사용하고 플레이어에게 던지는 것을 잊지 마십시오.

관련 문제