While studying for my
SCJP exam, I've started trying to create some classes which will work together to gather and compress files, then move them onto another machine.
I found much of this code on javaalmanac.com. I'm getting a strange error, telling me that I'm using unsafe or unchecked operations...
Who, me? What? Where!!??
package BackupClient;
import java.io.*;
import java.net.*;
import java.util.LinkedHashSet;
class Directory {
private LinkedHashSet lhs;
/** Creates a new instance of Directory */
protected LinkedHashSet Directory() {
lhs = new LinkedHashSet();
File dir = new File("c:\\");
visitAllDirsAndFiles(dir);
return lhs;
}
// Put all Files into lhs...
private void visitAllDirsAndFiles(File dir) {
lhs.add(dir);
if (dir.isDirectory()) {
String[] children = dir.list();
for (int i=0; i<children.length; i++) {
visitAllDirsAndFiles(new File(dir, children[i]));
} // for
} // if
} // visitAllDirsAndFiles
} // Directory
What am I doing wrong?
Marcus