How to Get Folder Name and Files Name From URL Using Java Code
===========GetFolder.java====================
package OrderDetails;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import org.json.simple.JSONObject;
/**
*
* @author ananddw
*/
public class GetFolder {
// File directory = new File("/home/ananddw/NetBeansProjects/Welcome/web/SA-DeskConfiguration");
public static void main(String[] args) {
File currentDir = new File("/home/ananddwivedi/NetBeansProjects/Welcome/web/SA-DeskConfiguration"); // current directory
displayDirectoryContents(currentDir);
}
public static void displayDirectoryContents(File dir) {
try {
File[] files = dir.listFiles();
for (File file : files) {
if (file.isDirectory()) {
System.out.println("Directory Name==>:" + file.getCanonicalPath());
displayDirectoryContents(file);
} else {
System.out.println("file Not Access===>" + file.getCanonicalPath());
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
package OrderDetails;
import java.io.File;
import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import org.json.simple.JSONObject;
/**
*
* @author ananddw
*/
public class GetFolder {
// File directory = new File("/home/ananddw/NetBeansProjects/Welcome/web/SA-DeskConfiguration");
public static void main(String[] args) {
File currentDir = new File("/home/ananddwivedi/NetBeansProjects/Welcome/web/SA-DeskConfiguration"); // current directory
displayDirectoryContents(currentDir);
}
public static void displayDirectoryContents(File dir) {
try {
File[] files = dir.listFiles();
for (File file : files) {
if (file.isDirectory()) {
System.out.println("Directory Name==>:" + file.getCanonicalPath());
displayDirectoryContents(file);
} else {
System.out.println("file Not Access===>" + file.getCanonicalPath());
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
Comments
Post a Comment