Ciao a tutti.
Sto cercando di leggere da file una lista.Ho pensato di usufruire della classe StringTokenizer andava tutto bene fino a quando non mi sono ritrovato a dover leggere l'ora.
Guardando capirete.
codice:
public class Boot
{
	public static void main(String[] args) //throws IOException
	{
		Scanner console = new Scanner(System.in);
		System.out.println("Input file: ");
		String inputFileName = console.next();
		System.out.println("Output file: ");
		String outputFileName = console.next();
		
		try
		{
			FileReader reader = new FileReader(inputFileName);
			Scanner in = new Scanner(reader);
			PrintWriter output = new PrintWriter(outputFileName);
			
			while(in.hasNextLine())			
			{
				String nomeStazione = in.next();
				Stazione stz = new Stazione(nomeStazione);
				
				int numBinario = in.nextInt();
				Binario b = new Binario(numBinario);
				
				String sigla = in.next();
				int numCarrozze = in.nextInt();
				double lunLocomotiva = in.nextDouble();
				int lunCarrozze = in.nextInt();
				
				StringTokenizer st = new StringTokenizer(in.next()," ");
				
				Calendar calendar = new GregorianCalendar();
			//	int orarioArrivo = in.nextInt();
				calendar.set(Calendar.HOUR,in.nextInt());
				calendar.set(Calendar.MINUTE,in.nextInt());
				
				Treno t = new Treno(st.nextToken(),Integer.parseInt(st.nextToken()),Double.parseDouble(st.nextToken()),Integer.parseInt(st.nextToken()),
						Integer.parseInt(calendar.set(Calendar.HOUR,st.nextToken());							//Leggi la succesiva riga
				System.out.println(t);
			}
			
			output.close();			//Quando si termina di scrivere chiude il file.
		}
		catch(IOException e)
		{
			System.out.println("Error processing file: "+e);
		}
	}
}
Questa è la lista che devo caricare.
[code]
Salerno
1
Intercity 354 6 29.9 28 10:20 0 21
Eurostar 745 10 32.89 35 11:10 true
Eurostar 232 11 32.89 35 17:10 false
2
Eurostar 745 10 32.89 35 15:10 true
Intercity 354 6 29.9 28 10:30 0 21
3
Intercity 354 6 29.9 28 10:20 0 21
Eurostar 745 10 32.89 35 11:10 true
Eurostar 232 11 32.89 35 17:10 false
3
Intercity 354 6 29.9 28 10:20 0 21
Eurostar 745 10 32.89 35 11:10 true
Eurostar 232 11 32.89 35 17:10 false
1
Eurostar 232 11 32.89 35 14:10 false
[\code]

Il problema sta nell'ora perchè non so come trattarlo dato che nella classe Treno ho solo una variabile istanza Calendar orarioArrivo.
invece devo passargli ore e minuti.
Come faccio?
Spero di essere stato chiaro per qualsiasi cosa sono incollato davanti al pc!