Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

File search crashing in sun folder

807569Jun 2 2006 — edited Jun 2 2006
I have been at this for hours and I really have no idea what to try next. I am writing a program to search the contents of a hard drive and delete certain files for the company I am working for. I have written the program in a .js file and it works perfectly. To improve my Java knowledge I decided to rewrite the same program in Java and I am receiving a very odd error.

When I run the program it correctly traverser my C:\ drive deleting every file I tell it to until it gets to C:\Sun. It searches through the Sun folder and just as it is checking the last file I get a "NullPointerException" error and I can't figure it out to save my life!!


Heres my code:
import java.io.File;

class findIt
{
	public static void main (String[] args)
	{
		System.out.println("Searching in java");
		findTheFiles("C:\\", args);
	
	}//main

	private static void findTheFiles(String f, String[] toFind)
	{
		File path = new File(f);
		File[] contents = path.listFiles();

Message was edited by: 
        wrconkling                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 30 2006
Added on Jun 2 2006
3 comments
97 views