can someone help me understand what i'm doing wrong here. attempted to run, program builds but no output is generated and the compiler does'nt generate an error message.

thank you all.

import java.util.Scanner;
import java.io.*;
import java.util.ArrayList;


public class arrayManipulator 
{

                 public static void main(String[] args) throws IOException
	{
		ArrayList<Integer> myArray = new ArrayList<Integer>();
		
		Scanner s = null;
		try 
		{
			s = new Scanner(new BufferedReader (new FileReader("usrnames.txt")));
				while(s.hasNext())
				{
					if(s.hasNextInt())
					{
						for(int i=0; i<myArray.size(); i++)
						{
						myArray.set(i, s.nextInt());
						System.out.print(" "+myArray.get(i));
						}
					}
				}
		}
		finally
		{ s.close();
		}

	}

Here's a way to filter out what you need without worrying about hideous "blocks" from the Scanner class--

import java.util.Scanner;
import java.io.*;
import java.util.ArrayList;

public class arrayManipulator{
        public static void main(String... args) throws IOException{
		ArrayList<Integer> myArray = new ArrayList<Integer>(0);
		BufferedReader s = null;
		try{
			s = new BufferedReader(new FileReader("C:/Documents and Settings/Mark/My Documents/usrnames.txt"));
				while(s.ready()){
					String value = "" + (char)s.read();
					try{
						Integer x = Integer.parseInt(value);
						myArray.add(x);
					}catch(Exception e){
						continue;
					}
				}
				System.out.println(myArray);
		}finally{ 
			s.close();
		}
	}
}
This article has been dead for over six months. Start a new discussion instead.