i hv written code of seraching specific folder on user choice with threading implemented. but im getting nullpointer exception at l.statsWith() in thread class two and not with normal searching

public class onlyfolder
{
	static String z,l,w,e;
	static String y;
	static File f;
	static JFrame frame;
	static JPanel panel;
	static DefaultTableModel model;
	static JTable table;
	
									/*Insert rows in table method*/
	
	public static void InsertRows()
	{
    frame = new JFrame("Inserting rows in the table!");
    panel = new JPanel();
    String data[][] = {};
    String col[] = {"Name","Folder","Type","Date Modified"};
	model = new DefaultTableModel(data,col);
    table = new JTable(model);
	
	JScrollPane scrollPane = new JScrollPane(table);

    ItemListener itemListener = new ItemListener()
	{
      public void itemStateChanged(ItemEvent e) {
        JComboBox source = (JComboBox) e.getSource();
        int index = source.getSelectedIndex();

    }
    };

    JFrame frame = new JFrame("Resizing Table");
	Container contentPane = frame.getContentPane();
	contentPane.add(scrollPane, BorderLayout.CENTER);
	frame.setSize(600, 150);
    frame.setVisible(true);
	
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	
									/*Searching method*/
	
	public static void visit(File f2)
	{
		if(f2.isDirectory())
		{
			String x[] = f2.list();
			for(int i=0;i<x.length;i++)
			{
				File f3 = new File(f2,x[i]);
				if(f3.isDirectory())
				{ 
				l = f3.getName();
				if(l.equals(y)|| l.equalsIgnoreCase(y)|| l.startsWith(y))
				{	
					
					String p = f3.getParent();
                    File f4 = new File(p);
                    String u = f4.getName();
					long timestamp = f3.lastModified();
					Date d = new Date(timestamp);
					SimpleDateFormat sdf = new SimpleDateFormat( "EE yyyy/MM/dd hh:mm:ss aa zz" );
					String display = sdf.format(d);
					JFileChooser chooser = new JFileChooser();
					e = chooser.getTypeDescription(f3);
					model.insertRow(table.getRowCount(),new Object[]{l,u,e,display});
                }
				
					two t1= new two(new File(f2,x[i]),model);
					t1.start();
					visit(new File(f2,x[i]));
				}
			}
		}
		
	}
	public static void main(String ar[])throws Exception 
	{
		System.out.println("enter file to be searched");
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		y = br.readLine();
		f = new File(y);
		File f1 = new File("E:/programs");
		InsertRows();
		visit(f1);
	
	}
}

class two extends Thread
{
	File fs;
	static String y,l,e;
	static JFrame frame;
	static JPanel panel;
	static DefaultTableModel model;
	static JTable table;
	
	two(File f, DefaultTableModel model2)
	{
		fs = f;
		model = model2;
	}
	public void visit2(File fs)
	{
		if(fs.isDirectory())
		{
			String x[] = fs.list();
			for(int i=0;i<x.length;i++)
			{
				File f6 = new File(fs,x[i]);
				l = f6.getName();
				if(l.equals(y)|| l.equalsIgnoreCase(y)|| l.startsWith(y))
				{	
					
					String p = f6.getParent();
                    File f7 = new File(p);
                    String u = f7.getName();
					long timestamp = f6.lastModified();
					Date d = new Date(timestamp);
					SimpleDateFormat sdf = new SimpleDateFormat( "EE yyyy/MM/dd hh:mm:ss aa zz" );
					String display = sdf.format(d);
					JFileChooser chooser = new JFileChooser();
					e = chooser.getTypeDescription(f6);
					model.insertRow(table.getRowCount(),new Object[]{l,u,e,display});
                }
				if(f6.isDirectory())
				{ 
					visit2(new File(fs,x[i]));
				}
			}
		}
		
	}
	public void run()
	{
		visit2(fs);	
	}
}

Chances are "f6" does not exist and therefore you cannot get the name of it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.