Help - Java Error

Smock
Smock used Ask the Experts™
on
I'm trying to read specific values from several files and arrange those values onto a JTable respectively.

I was able to successfully do it with when it is reading just one file. However, the problem arose when it tried to read a bunch of files in various directories. An excerpt of the error that i received is shown below:

Exception in thread "main" java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
      at java.util.ArrayList.RangeCheck(Unknown Source)
      at java.util.ArrayList.get(Unknown Source)

Any help is much appreciated.
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import javax.swing.*;
import javax.swing.table.*;
 
public class TableProcessing extends JFrame
{
    JTable table;
    ArrayList<String> list = new ArrayList<String>();
    ArrayList<Item> data = new ArrayList<Item>();
    public TableProcessing()
    {
        ArrayList<String> columnNames = new ArrayList<String>(4);
        columnNames.add("Model #");
        columnNames.add("Program");
        columnNames.add("SN");
        columnNames.add("Station #");
        
        traverse(new File("//root/dir"));
        TableModel model = new ItemTableModel(data, columnNames);
//
        table = new JTable( model );
        table.setPreferredScrollableViewportSize(table.getPreferredSize());
//
        JScrollPane scrollPane = new JScrollPane( table );
        getContentPane().add( scrollPane );
    }
 
    class Item
    {
        String Name;
        String IDNum;
        String Number;
        String schoolID;
 
        public Item(String Name, String IDNum, String Number, String schoolID)
        {
            this.Name = Name;
            this.IDNum = IDNum;
            this.Number = Number;
            this.schoolID = schoolID;
        }
    }
 
    class ItemTableModel extends AbstractTableModel
    {
        List data;
        List columnNames;
 
        public ItemTableModel(List data, List columnNames)
        {
            this.data = data;
            this.columnNames = columnNames;
        }
 
        public String getColumnName(int col) { return columnNames.get(col).toString(); }
 
        public int getRowCount() { return data.size(); }
 
        public int getColumnCount() { return columnNames.size(); }
 
        public Class getColumnClass(int column) { return getValueAt(0, column).getClass(); }
 
        public boolean isCellEditable(int row, int column)
        {
            //if (column == 3)
                //return false;
           // else
                return false;
        }
 
        public Object getValueAt(int row, int column)
        {
            Item item = (Item)data.get( row );
 
            switch ( column )
            {
                case 0: return item.Name;
                case 1: return item.IDNum;
                case 2: return item.Number;
                case 3: return item.schoolID;
            }
 
            return null;
        }
 
        public void setValueAt(Object value, int row, int column)
        {
            Item item = (Item)data.get( row );
 
            switch ( column )
            {
                case 0:
                    item.Name = (String)value;
                    break;
                case 1:
                    item.IDNum = (String)value;
                    break;
                case 2:
                    item.Number = (String)value;
                    break;
                case 3:
                    item.schoolID = (String)value;
                    break;
            }
 
            fireTableCellUpdated(row, column);
 
                 }
    }

    public void traverse(File dir) {
            if (!dir.exists()) {
                System.out.println("Does not exist " + dir);
            }

            if (dir.isDirectory()) {
                File[] children = dir.listFiles();

                for (int i = 0; i < children.length; i++) {
                    traverse(children[i]);
                }
            } 
            else if (dir.getName().matches("data.txt")) {
    	    ;
    	        	    else if (find(dir, "123456")) {
    		System.out.println(dir.getParentFile());
    		if (dir.getParentFile().exists()){
    		
    			ScannerReadFile(dir.getName());
    		}
    	    }
       }
    }    
    
    
    public boolean find(File f, String searchString) {
        boolean result = false;
        Scanner in = null;
        try {
            in = new Scanner(new FileReader(f));
            while(in.hasNextLine() && !result) {
                result = in.nextLine().indexOf(searchString) >= 0;
                
            }
        }
        catch(IOException e) {
            e.printStackTrace();      
        }
        finally {
            try { in.close() ; } catch(Exception e) { /* ignore */ }  
        }
        return result;
    }
   

 
	public void ScannerReadFile(String string){
   	
    	//file = new File("data.txt");
         
         //get an Iterator object for ArrayList using iterator() method.
        
         
           try {
        	   FileReader reader = new FileReader(string);
               BufferedReader in = new BufferedReader(reader);
               //
               // Create a new Scanner object which will read the data from the 
               // file passed in. To check if there are more line to read from it
               // we check by calling the scanner.hasNextLine() method. We then
               // read line one by one till all line is read.
               //
               Scanner scanner = new Scanner(string);
              
               //output = "";
               while (scanner.hasNextLine()) {
                   String nl = scanner.nextLine();
                   //System.out.println(line);
                   if (parseString(nl) != null) {
                   // output += parseString(nl);
                    list.add(parseString(nl));
                          
                   } 
                  
               }
               
               System.out.println(list);
               System.out.println();
               
               for(int i=0;i<list.size();i++)
               {
               System.out.println(list.get(i));
                            
               }
		 data.add(new Item(list.get(0), list.get(1), list.get(2), list.get(3)));
                            
              try {
				in.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
               //System.out.println(list);
           } catch (FileNotFoundException e) {
               e.printStackTrace();
           }
    	
    }
    
    private String parseString(String line) {
        
        if (line.contains("Name") || line.contains("ID") || line.contains("Number")|| line.contains("SchoolID")) {
        	if(line.contains("num")){
        		return null;
        	}
        	else{
            line = line.substring(line.indexOf("=") + 1, line.length());
            //return line + "\n";
            return line;
           
        	}
        } else {
            return null;
        }
    } 
    
    public static void main(String[] args)
    {
    	
        TableProcessing frame = new TableProcessing();
        frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
        frame.pack();
        frame.setLocationRelativeTo( null );
        frame.setVisible(true);
    }


}

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
if you are getting this error at line number 203, then it is apparently because list is not having that many items (at least 4).
from which line is your exception being thrown?

Author

Commented:
data.add(new Item(list.get(0), list.get(1), list.get(2), list.get(3)));

The above gives me errors
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

@Smock: check my first reply

Author

Commented:
I'm not really sure what that means. I believe The files it's reading has that many items.
before that line put this statement, and tell me what that means

System.out.println(list.size());

Author

Commented:
I'm getting 0. i don't know why. please help
Top Expert 2016

Commented:
That means reading the file has not filled the list

Author

Commented:
What am i doing wrong? Can you please help with that?
Top Expert 2016

Commented:
Please post the code you're running. You haven't done so, since the above won't even compile
can you post the contents of data.txt which you are reading? as per your logic of parsing a line in a file, that file should have atleast 4 lines which succeed the parseString method test

Author

Commented:
data file has the following:

IDNum = 0
Name=Joe
Last Name=Doe
Number=21
Gender=Male
School = middle school
schoolID = 1234
Top Expert 2016

Commented:
There's not much point answering questions about code that you're not running

Author

Commented:
I just changed the variables in my code. The code is essentially the same thing. Anyway, I have posted it again.

data.txt contains:

Last Name = Doe
First Name = John
Age = 21
ID Number = 011234
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import javax.swing.*;
import javax.swing.table.*;
 
public class TableProcessing extends JFrame
{
    JTable table;
    ArrayList<String> list = new ArrayList<String>();
    ArrayList<Item> data = new ArrayList<Item>();
    public TableProcessing()
    {
        ArrayList<String> columnNames = new ArrayList<String>(4);
        columnNames.add("Last Name");
        columnNames.add("First Name");
        columnNames.add("Age");
        columnNames.add("ID Number");
        
        traverse(new File("//Root/dir"));
        TableModel model = new ItemTableModel(data, columnNames);

        table = new JTable( model );
        table.setPreferredScrollableViewportSize(table.getPreferredSize());

        JScrollPane scrollPane = new JScrollPane( table );
        getContentPane().add( scrollPane );
    }
 
    class Item
    {
        String lastName;
        String firstName;
        String Age;
        String idNum;
 
        public Item(String lastName, String firstName, String Age, String idNum)
        {
            this.lastName = lastName;
            this.firstName = firstName;
            this.Age = Age;
            this.idNum = idNum;
        }
    }
 
    class ItemTableModel extends AbstractTableModel
    {
        List data;
        List columnNames;
 
        public ItemTableModel(List data, List columnNames)
        {
            this.data = data;
            this.columnNames = columnNames;
        }
 
        public String getColumnName(int col) { return columnNames.get(col).toString(); }
 
        public int getRowCount() { return data.size(); }
 
        public int getColumnCount() { return columnNames.size(); }
 
        public Class getColumnClass(int column) { return getValueAt(0, column).getClass(); }
 
        public boolean isCellEditable(int row, int column)
        {
            //if (column == 3)
                //return false;
           // else
                return false;
        }
 
        public Object getValueAt(int row, int column)
        {
            Item item = (Item)data.get( row );
 
            switch ( column )
            {
                case 0: return item.lastName;
                case 1: return item.firstName;
                case 2: return item.Age;
                case 3: return item.idNum;
            }
 
            return null;
        }
 
        public void setValueAt(Object value, int row, int column)
        {
            Item item = (Item)data.get( row );
 
            switch ( column )
            {
                case 0:
                    item.lastName = (String)value;
                    break;
                case 1:
                    item.firstName = (String)value;
                    break;
                case 2:
                    item.Age = (String)value;
                    break;
                case 3:
                    item.idNum = (String)value;
                    break;
            }
 
            fireTableCellUpdated(row, column);
 
                    }
    }

    public void traverse(File dir) {
            if (!dir.exists()) {
                System.out.println("Does not exist " + dir);
            }

            if (dir.isDirectory()) {
                File[] children = dir.listFiles();

                for (int i = 0; i < children.length; i++) {
                    traverse(children[i]);
                }
            } 
            else if (dir.getName().matches("data.txt")) {
    	      if (find(dir, "123456")) {
    		System.out.println(dir.getParentFile());
    		if (dir.getParentFile().exists()){
    		
    			ScannerReadFile(dir.getName());
    		}
    	    }
       }
    }    
    
    
    public boolean find(File f, String searchString) {
        boolean result = false;
        Scanner in = null;
        try {
            in = new Scanner(new FileReader(f));
            while(in.hasNextLine() && !result) {
                result = in.nextLine().indexOf(searchString) >= 0;
                
            }
        }
        catch(IOException e) {
            e.printStackTrace();      
        }
        finally {
            try { in.close() ; } catch(Exception e) { /* ignore */ }  
        }
        return result;
    }
   

 
	public void ScannerReadFile(String string){
   	
    	         
           try {
        	   FileReader reader = new FileReader(string);
               BufferedReader in = new BufferedReader(reader);
               //
               // Create a new Scanner object which will read the data from the 
               // file passed in. To check if there are more line to read from it
               // we check by calling the scanner.hasNextLine() method. We then
               // read line one by one till all line is read.
               //
               Scanner scanner = new Scanner(string);
              
               //output = "";
               while (scanner.hasNextLine()) {
                   String nl = scanner.nextLine();
                   //System.out.println(line);
                   if (parseString(nl) != null) {
                   // output += parseString(nl);
                    list.add(parseString(nl));
                          
                   } 
                  
               }
               
               System.out.println(list);
               System.out.println();
               
               for(int i=0;i<list.size();i++)
               {
               System.out.println(list.get(i));
                            }
               System.out.println(list.size());
               
              
              try {
				in.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
               //System.out.println(list);
           } catch (FileNotFoundException e) {
               e.printStackTrace();
           }
    	
    }
    
    private String parseString(String line) {
        
        if (line.contains("Last Name") || line.contains("First Name") || line.contains("Age")|| line.contains("ID Number")) {
        
            line = line.substring(line.indexOf("=") + 1, line.length());
            //return line + "\n";
            return line;
           
        	
        } else {
            return null;
        }
    } 
    
    public static void main(String[] args)
    {
    	
        TableProcessing frame = new TableProcessing();
        frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
        frame.pack();
        frame.setLocationRelativeTo( null );
        frame.setVisible(true);
    }


}

Open in new window

Top Expert 2016
Commented:
Quite a few changes in the following. Back up your original source and study the differences carefully
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;

import javax.swing.*;
import javax.swing.table.*;


public class TableProcessing extends JFrame {
    JTable table;
    ArrayList<String> list = new ArrayList<String>();
    ArrayList<Item> data = new ArrayList<Item>();

    public TableProcessing() {
        ArrayList<String> columnNames = new ArrayList<String>(4);
        columnNames.add("Last Name");
        columnNames.add("First Name");
        columnNames.add("Age");
        columnNames.add("ID Number");

        //traverse(new File("//Root/dir"));
        traverse(new File("/tmp/root"));

        TableModel model = new ItemTableModel(stringsToItems(list), columnNames);

        table = new JTable(model);
        table.setPreferredScrollableViewportSize(table.getPreferredSize());

        JScrollPane scrollPane = new JScrollPane(table);
        getContentPane().add(scrollPane);
    }

    public void traverse(File dir) {
        if (!dir.exists()) {
            System.out.println("Does not exist " + dir);
        }

        if (dir.isDirectory()) {
            File[] children = dir.listFiles();

            for (int i = 0; i < children.length; i++) {
                traverse(children[i]);
            }
        } else if (dir.getName().matches("data.txt")) {
            if (find(dir, "123456")) {
                System.out.println(dir.getParentFile());

                if (dir.getParentFile().exists()) {
                    //ScannerReadFile(dir.getName());
                    ScannerReadFile(dir);
                }
            }
        }
    }

    public boolean find(File f, String searchString) {
        boolean result = false;
        Scanner in = null;

        try {
            in = new Scanner(new FileReader(f));

            while (in.hasNextLine() && !result) {
                result = in.nextLine().indexOf(searchString) >= 0;
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (Exception e) { /* ignore */
            }
        }

        return result;
    }

    public void ScannerReadFile(File f) {
	Scanner scanner = null;
        try {

            //
            // Create a new Scanner object which will read the data from the 
            // file passed in. To check if there are more line to read from it
            // we check by calling the scanner.hasNextLine() method. We then
            // read line one by one till all line is read.
            //
            scanner = new Scanner(f);

            //output = "";
            while (scanner.hasNextLine()) {
                String nl = scanner.nextLine();

                //System.out.println(line);
                if (parseString(nl) != null) {
                    // output += parseString(nl);
		    list.add(parseString(nl));
		}
	    }

	    System.out.println(list);
	    System.out.println();

	    for (int i = 0; i < list.size(); i++) {
		System.out.println(list.get(i));
	    }

	    System.out.println(list.size());


	    //System.out.println(list);
	} catch (FileNotFoundException e) {
	    e.printStackTrace();
	}
	finally {
	    scanner.close();
	}
    }

    private String parseString(String line) {
	if (line.contains("Last Name") || line.contains("First Name") ||
		line.contains("Age") || line.contains("ID Number")) {
	    line = line.substring(line.indexOf("=") + 1, line.length());

	    //return line + "\n";
	    return line;
	} else {
	    return null;
	}
    }

    public static void main(String[] args) {
	TableProcessing frame = new TableProcessing();
	frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
	frame.pack();
	frame.setLocationRelativeTo(null);
	frame.setVisible(true);
    }

    /**
     * Must convert data collected of String type
     * to type Item for the TableModel
     */

    private List<Item> stringsToItems(List<String> strings) {
	List<Item> result = new ArrayList<Item>(strings.size() / 4);
	Iterator<String> i = strings.iterator();
	while(i.hasNext()) {
	    result.add(new Item(i.next(),i.next(), i.next(), i.next()));
	}
	return result;
    }

    class Item {
	String lastName;
	String firstName;
	String Age;
	String idNum;

	public Item(String lastName, String firstName, String Age, String idNum) {
	    this.lastName = lastName;
	    this.firstName = firstName;
	    this.Age = Age;
	    this.idNum = idNum;
	}
    }

    class ItemTableModel extends AbstractTableModel {
	List data;
	List columnNames;

	public ItemTableModel(List data, List columnNames) {
	    this.data = data;
	    this.columnNames = columnNames;
	}

	public String getColumnName(int col) {
	    return columnNames.get(col).toString();
	}

	public int getRowCount() {
	    return data.size();
	}

	public int getColumnCount() {
	    return columnNames.size();
	}

	public Class getColumnClass(int column) {
	    return getValueAt(0, column).getClass();
	}

	public boolean isCellEditable(int row, int column) {
	    //if (column == 3)
	    //return false;
	    // else
	    return false;
	}

	public Object getValueAt(int row, int column) {
	    Item item = (Item) data.get(row);

	    switch (column) {
		case 0:
		    return item.lastName;

		case 1:
		    return item.firstName;

		case 2:
		    return item.Age;

		case 3:
		    return item.idNum;
	    }

	    return null;
	}

	public void setValueAt(Object value, int row, int column) {
	    Item item = (Item) data.get(row);

	    switch (column) {
		case 0:
		    item.lastName = (String) value;

		    break;

		case 1:
		    item.firstName = (String) value;

		    break;

		case 2:
		    item.Age = (String) value;

		    break;

		case 3:
		    item.idNum = (String) value;

		    break;
	    }

	    fireTableCellUpdated(row, column);
	}
    }
}

Open in new window

Top Expert 2016

Commented:
Oops

>>
       //traverse(new File("//Root/dir"));
        traverse(new File("/tmp/root"));
>>

You'll want to switch that back to your path

Author

Commented:
Thanks. I tried your code but i'm getting the output in the console but not in the table.
Top Expert 2016

Commented:
I'll take a look. There's no 'age' here btw:

http:#33950887
Top Expert 2016

Commented:
It will also cause your parseString method to fail since the field names are wrong
Top Expert 2016

Commented:
Making those data file correction allows it to run for me:
java.png

Author

Commented:
Hi,
Thanks for your help. I did exactly the same thing that you did and I still am not getting a table. I don't know why that is. I don't see the Jtable at all.

I think the problem might be with the List<Item> stringsToItems(List<String> strings) method. does it need to be called in ScannerReadFile()?

data.txt has the following:


Last Name = Doe
First Name = John
Number = 123456
Age = 21
ID Number = 011234

The code is meant to check a bunch of  files to see if '123456' is included in any of the files. If it is, it extracts last name, first name, age, id number and arranges them in a Jtable.
I don't know why you are getting a result and i'm not.

thanks in advance for your help.
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;

import javax.swing.*;
import javax.swing.table.*;
 
public class TableProcessing extends JFrame
{
    JTable table;
    ArrayList<String> list = new ArrayList<String>();
    ArrayList<Item> data = new ArrayList<Item>();
    
    public TableProcessing()
    {
        ArrayList<String> columnNames = new ArrayList<String>(4);
        columnNames.add("Last Name");
        columnNames.add("First Name");
        columnNames.add("Age");
        columnNames.add("ID Number");
        
        traverse(new File("//Root/dir"));
      
        //TableModel model = new ItemTableModel(data, columnNames);
        TableModel model = new ItemTableModel(stringsToItems(list), columnNames);


        table = new JTable( model );
        table.setPreferredScrollableViewportSize(table.getPreferredSize());
//
        JScrollPane scrollPane = new JScrollPane( table );
        getContentPane().add( scrollPane );
    }
    
    public void traverse(File dir) {
        if (!dir.exists()) {
            System.out.println("Does not exist " + dir);
        }

        if (dir.isDirectory()) {
            File[] children = dir.listFiles();

            for (int i = 0; i < children.length; i++) {
                traverse(children[i]);
            }
        } 
        else if (dir.getName().matches("data.txt")) {
	   // ;
		   if (find(dir, "123456")) {
		System.out.println(dir.getParentFile());
		if (dir.getParentFile().exists()){
		
			ScannerReadFile(dir);
		}
	    }
   }
}    


    public boolean find(File f, String searchString) {
    boolean result = false;
    Scanner in = null;
    try {
        in = new Scanner(new FileReader(f));
        while(in.hasNextLine() && !result) {
            result = in.nextLine().indexOf(searchString) >= 0;
            
        }
    }
    catch(IOException e) {
        e.printStackTrace();      
    }
    finally {
        try { in.close() ; } catch(Exception e) { /* ignore */ }  
    }
    return result;
    }


public void ScannerReadFile(File f) {
	Scanner scanner = null;
        try {

            //
            // Create a new Scanner object which will read the data from the 
            // file passed in. To check if there are more line to read from it
            // we check by calling the scanner.hasNextLine() method. We then
            // read line one by one till all line is read.
            //
            scanner = new Scanner(f);

            //output = "";
            while (scanner.hasNextLine()) {
                String nl = scanner.nextLine();

                //System.out.println(line);
                if (parseString(nl) != null) {
                    // output += parseString(nl);
		    list.add(parseString(nl));
		}
	    }

	 //   System.out.println(list);
	    System.out.println();

	    for (int i = 0; i < list.size(); i++) {
		//System.out.println(list.get(i));
	    }

	   // System.out.println(list.size());


	    //System.out.println(list);
	} catch (FileNotFoundException e) {
	    e.printStackTrace();
	}
	finally {
	    scanner.close();
	}
    }


	 private String parseString(String line) {
        
        if (line.contains("Last Name") || line.contains("First Name") || line.contains("Age")|| line.contains("ID Number")) {
        
            line = line.substring(line.indexOf("=") + 1, line.length());
            //return line + "\n";
            return line;
           
        	
        } else {
            return null;
        }
    } 


	 public static void main(String[] args)
	    {
	    	
	        TableProcessing frame = new TableProcessing();
	        frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
	        frame.pack();
	        frame.setLocationRelativeTo( null );
	        frame.setVisible(true);
	    }

    
    private List<Item> stringsToItems(List<String> strings) {
    	List<Item> result = new ArrayList<Item>(strings.size() / 4);
    	Iterator<String> i = strings.iterator();
    	while(i.hasNext()) {
    	    result.add(new Item(i.next(),i.next(), i.next(), i.next()));
    	    
    	}
    	return result;
    	
  }
    
 
    class Item
    {
        String lastName;
        String firstName;
        String Age;
        String idNum;
 
        public Item(String lastName, String firstName, String Age, String idNum)
        {
            this.lastName = lastName;
            this.firstName = firstName;
            this.Age = Age;
            this.idNum = idNum;
        }
    }
 
    class ItemTableModel extends AbstractTableModel
    {
        List data;
        List columnNames;
 
        public ItemTableModel(List data, List columnNames)
        {
            this.data = data;
            this.columnNames = columnNames;
        }
 
        public String getColumnName(int col) { return columnNames.get(col).toString(); }
 
        public int getRowCount() { return data.size(); }
 
        public int getColumnCount() { return columnNames.size(); }
 
        public Class getColumnClass(int column) { return getValueAt(0, column).getClass(); }
 
        public boolean isCellEditable(int row, int column)
        {
            //if (column == 3)
                //return false;
           // else
                return false;
        }
 
        public Object getValueAt(int row, int column)
        {
            Item item = (Item)data.get( row );
 
            switch ( column )
            {
                case 0: return item.lastName;
                case 1: return item.firstName;
                case 2: return item.Age;
                case 3: return item.idNum;
            }
 
            return null;
        }
 
        public void setValueAt(Object value, int row, int column)
        {
            Item item = (Item)data.get( row );
 
            switch ( column )
            {
                case 0:
                    item.lastName = (String)value;
                    break;
                case 1:
                    item.firstName = (String)value;
                    break;
                case 2:
                    item.Age = (String)value;
                    break;
                case 3:
                    item.idNum = (String)value;
                    break;
            }
 
            fireTableCellUpdated(row, column);
 
            //  Update dependent cells
 
                 }
    }

   

 



}

Open in new window

Top Expert 2016

Commented:
>>The code is meant to check a bunch of  files to see if '123456' is included in any of the files.

Exactly. The file you posted doesn't have that, so it won't be processed. It'll be ignored

Author

Commented:
The files in my directory have that. I'm seeing the results on the console and not on the Jtable - that is the problem! I don't know why the table isn't popping up when i run it.
Top Expert 2016

Commented:
>>The files in my directory have that

OK. It seems odd that you posted an example of data that will never get collected. Can you post an example of an actual file of data that should be collected?

Author

Commented:
Last Name = Doe
First Name = John
Number = 123456
Age = 21
ID Number = 011234

Top Expert 2016

Commented:
Works for me. Assuming this data is not confidential, change at the command line to the directory containing 'Root', run the following and attach the named zip here please
jar cfM files.zip Root

Open in new window

Top Expert 2007

Commented:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial