Dear all,
I am a newbie in Java, I got the following problem:
I am going through a list of directories. The programm looks inside each directory for specific files and writes them in an File-array. Then it goes through this array and executes the external programm "naccess". naccess takes a file as input and produces 4 output files. Unfortunatly the result files are not in the directory where the input file is (/home/tj/test), they are in the java directory (/home/tj/workspace/Set).
Is there a way to tell java to execute the programm in the acutal folder?
I paste some of the source code, hope it is not to much/less:
public void scanDir(File filePath){
//Just get zipped Files
FileExtensionFilter filter = new FileExtensionFilter(".pdb");
String[] entries = filePath.list(filter);
//entry contains no files
if (entries == null || entries.length < 1){
return;
}
//go through file list
for (int i = 0 ; i < entries.length ; i++){
File entry = new File(filePath, entries);
if (entry.isDirectory()){
scanDir(entry);
}else{
String[] programm = {"/bin bash -c '/home/tj/naccess'", entry.getAbsolutePath()};
positivSet.execute(programm);
}//else scanDir()
}//for
}//scanDir()
//positiveSet.execute is pretty much an adaption of the streamgobbler class which can be found here:
http://www.javaworld.com/javaworld/j...229-traps.html
Sadly there is no switch in naccess to redirect the output, it always writes the result files in the executing folder.
Thanks very much,
Thomas