Answer the question
In order to leave comments, you need to log in
Null pointer exception?
package example;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class Example {
static List<String> listpaths;
public static void main(String[] args) throws Exception {
//GeneratePlaylist g = new GeneratePlaylist();
//g.LoadFromFiles();
listpaths = new ArrayList<String>();
String currentWorkingDir = System.getProperty("Z:\\Радио");
File file = new File(currentWorkingDir);
showFilesAndDirectoryes(file);
listpaths.clear();
}
public static void showFilesAndDirectoryes (File f) throws Exception {
File[] files = f.listFiles();
for(File p:files){
if (!p.isDirectory ()) {
System.out.println (p.getName ());
listpaths.add(p.getName());
System.out.println (p.getAbsolutePath());
}
if (p.isDirectory ()) {
try {
showFilesAndDirectoryes (p);
}
catch(Exception e){
e.printStackTrace();
}
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Reading the doc to System.getProperty...
@return the string value of the system property, or null
if there is no property with that key.
@throws NullPointerException If thepathname
argument isnull
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question