How JSP traversed
The purpose is to get all file names in a certain directory.
File has 2 methods to be used for you:
1, String [] list ();
2, file [] listfiles ();
When using the for loop, the file name will be traversed. After traversing, inserting the database is very simple -
The following code experiments are passed: {list all file names under DIR, except for the directory name}
CODE:
Import java.io. *;
Public class test {
Public static void main (String [] args) {
Try {
File Dir = New File ("D: / CODES");
String [] fs = dir.list ();
For (int i = 0; i IF (fs [i] .indexof (".")! = - 1) System.out.println (FS [i]); } } Catch (Exception E) {E.PrintStackTrace (); } }