wood burning stoves 2.0*
The moose likes I/O and Streams and the fly likes Unable to resolve Null Pointer Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Unable to resolve Null Pointer Exception " Watch "Unable to resolve Null Pointer Exception " New topic

Unable to resolve Null Pointer Exception

Dtech Pace

Joined: Nov 19, 2011
Posts: 2
Unable to resolve Null Pointer Exception
Kindly provide solution...

import java.io.*;
public class SearchTxtFiles
private static String p="",dp="";
private static String[] paths;
private static String files;
private static int i=0,ti=0,in=0;

public static void main(String[] args) throws IOException
SearchTxtFiles vrp=new SearchTxtFiles();
int a=0;
try{ a=vrp.callSystem();} catch(IOException ie){}
System.out.println("total : "+a);

final int callSystem()throws IOException

File[] roots = File.listRoots();

for(int k=0;k<roots.length;k++)
File f= new File(roots[k]+"\\");
File[] lf=f.listFiles();
for(int a=0;a<lf.length;a++)

return ti;

public final static void visitAllFiles(File dir)
if (dir.isDirectory())
String[] children = dir.list();
for (int i=0; i<children.length; i++)
visitAllFiles(new File(dir, children[i]));
i++; ti=ti+i;

Paul Clapham

Joined: Oct 14, 2005
Posts: 18541

The solution would be to look at the stack trace, which tells you what line of code threw the exception. Then examine that code to see what variables are being dereferenced, and investigate which of them is null and what you can do about that.

Posting the code with no further explanation is not a strategy which will get you anywhere.
I agree. Here's the link: http://aspose.com/file-tools
subject: Unable to resolve Null Pointer Exception
Similar Threads
problem in copying the directory
can i use java to check the disk usage?
FileName to write to a .txt File
Server Program - Responding To Post Requests From HTML pg.
Couldn't check status of file/directory with casting error