java 怎么通过url获取远程服务器上某个文件夹下的所有文件名
/
读取某个文件夹下的所有文件
/
public static boolean readfile(String filepath) throws FileNotFoundException, IOException {
try {
File file = new File(filepath);
if (!fileisDirectory()) {
Systemoutprintln("文件");
Systemoutprintln("path=" + filegetPath());
Systemoutprintln("absolutepath=" + filegetAbsolutePath());
Systemoutprintln("name=" + filegetName());
} else if (fileisDirectory()) {
Systemoutprintln("文件夹");
String[] filelist = filelist();
for (int i = 0; i < filelistlength; i++) {
File readfile = new File(filepath + "\\" + filelist[i]);
if (!readfileisDirectory()) {
Systemoutprintln("path=" + readfilegetPath());
Systemoutprintln("absolutepath="
+ readfilegetAbsolutePath());
Systemoutprintln("name=" + readfilegetName());
} else if (readfileisDirectory()) {
readfile(filepath + "\\" + filelist[i]);
}
}
}
} catch (FileNotFoundException e) {
Systemoutprintln("readfile() Exception:" + egetMessage());
}
return true;
}
要在该电脑上写一个服务器的程序,然后连接过去获取返回
~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~
0条评论