When uploading files, there may be a lot of files, we know that when you put all the files in the same directory, open the directory is very slow
This also shows that the efficiency of finding files is reduced
We put the files in different directories, so as to improve the efficiency of file search
Folder hierarchy idea
Create a two-level directory with a 16-in-one naming folder so you can put files in 16*16=256 folders
1String str= "Lkjhgfds.jpg";//file name2 intA=str.hashcode ();//the hash value of the file name3 intB=a & 0xf;//4 digits after taking4 System.out.println (b);5String bin1=integer.tohexstring (b);//convert to 16 binary6System.out.println (bin1);//bin can be the first level directory name7 8 9 intC= (a>>4) & 0xf;//take last four bits front four bitsTen System.out.println (c); OneString bin2=integer.tohexstring (c);//convert to 16 binary ASystem.out.println (BIN2);//bin2 can be used as a second-level directory name
1 //make up a saved directory2savepath=path+ "/" +Savepath;3 //determine if a directory exists4File f =NewFile (savepath);5 if(!f.exists ()) {6 //Create a directory7 f.mkdirs ();8}
Folder rating Save file