1.write a console program to list all directories and files in a hard drive
2.write a TCP/IP cilent server talk program to transfer a film from cilent to the serverone program is tcp server and one program is TCP cilent. TCP server will wait for the cilent connection and cilent will send a file(for example, c:\abc.jpg) to the server side and save it to any temporay directory you like.
3. write a program to take the database connection string as the input and list all the user tables in the database and first row of each tables in the database.
2.write a TCP/IP cilent server talk program to transfer a film from cilent to the serverone program is tcp server and one program is TCP cilent. TCP server will wait for the cilent connection and cilent will send a file(for example, c:\abc.jpg) to the server side and save it to any temporay directory you like.
3. write a program to take the database connection string as the input and list all the user tables in the database and first row of each tables in the database.
import java.io.*; class Test
{
static void getDir(String strPath) throws Exception
{
try
{
File f=new File(strPath);
if(f.isDirectory())
{
File[] fList=f.listFiles();
for(int j=0;j<fList.length;j++)
{
if(fList[j].isDirectory())
{
System.out.println(fList[j].getPath());
getDir(fList[j].getPath()); //在getDir函数里面又调用了getDir函数本身
}
}
for(int j=0;j<fList.length;j++)
{ if(fList[j].isFile())
{
System.out.println(fList[j].getPath());
} }
}
}
catch(Exception e)
{
System.out.println("Error: " + e);
} } public static void main(String[] args)
{
String strPath="e:\\wt";
System.out.println(strPath); try
{
getDir(strPath);
}
catch(Exception e)
{ }
}
}
可怎么运行后显示的是:e:\wt
???
如你要得到C盘下的所有目录和文件。就改成
c:\\