+ 1
I want to input many files like a folder or select some of a folder
2 Answers
+ 1
String path = "C:" + File.separator + "hello" + File.separator + "hi.txt";
// Use relative path for Unix systems
File f = new File(path);
f.getParentFile().mkdirs();
f.createNewFile(); // try this
0
You have to use a loop to input all the file names in an array :
while(input.hasNext()) // Loop until end-of-line
arr[i] = input.nextLine(); // character
input is the object of Scanner.
Now use this array 'arr' to read the filenames. OR
If you are selecting a folder, then use 'File' object to list all the containing files :
if(fileobj.isDirectory()) //checking for directory
arr[] = fileobj.list();
//inputting the contents of folder
Its not a complete code but a guideline. I hope this helps you. Happy Coding!