java 查看文件夹下面所有文件以及文件夹
import java.io.File;
import java.util.Date;
import java.util.Iterator;
import java.util.Vector;
import java.text.SimpleDateFormat;
public class FileViewer {
File myDir;
File[] contents;
Vector vectorList;
Iterator currentFileView;
File currentFile;
String path;
public FileViewer() {
path = new String("");
vectorList = new Vector();
}
public FileViewer(String path) {
this.path = path;
vectorList = new Vector();
}
/**
* 设置浏览的路径
*/
public void setPath(String path) {
this.path = path;
}
/***
* 返回当前目录路径
*/
public String getDirectory() {
return myDir.getPath();
}
/**
* 刷新列表
*/
public void refreshList() {
if (this.path.equals("")) {
path = "c:\\";
}
myDir = new File(path);
vectorList.clear();
contents = myDir.listFiles();
//重新装入路径下文件
for (int i = 0; i < contents.length; i++) {
vectorList.add(contents[i]);
}
currentFileView = vectorList.iterator();
}
/**
* 移动当前文件集合的指针指到下一个条目
* @return 成功返回true,否则false
*/
public boolean nextFile() {
while (currentFileView.hasNext()) {
currentFile = (File) currentFileView.next();
return true;
}
return false;
}
/**
* 返回当前指向的文件对象的文件名称
*/
public String
相关文档:
1.基本概念的理解
绝对路径:绝对路径就是你的主页上的文件或目录在硬盘上真正的路径,(URL和物理路径)例如:
C:\xyz\test.txt 代表了test.txt文件的绝对路径。http://www.sun.com/index.htm也代表了一个
URL绝对路径。
相对路径:相对与某个基准目录的路径。包含Web的相对路径(HTML中的相对目录),例如 ......
1.关于struts 的API
struts 的官方网站,介绍的很是全面
http://struts.apache.org/struts-doc-1.2.x/userGuide
这个是struts 的官方网站提供的关于标签库的
这个是可以下载到原码的
http://www.apache.org/dist
2.下面这个就是著名的commons 包的下载地址
&n ......
现在自学Java中,结合网上搜索、书上描写及自己的理解,对接口有一些理解,希望与大家分享一下。
接口是不同类的相同方法的集合,不过它只给出了方法的定义,并没有给出具体的实现。
就像一群杀手,有人叫他去杀一个人,他们有相同的行为——杀死目标,这就像接口,不同的杀手会用不同的手段,这如方法的具体实 ......
1. 从sun主页下载JDK for Linux版本,我的是jdk-6u14-linux-i586.bin。
2. 改为可操作文件,chmod +x jdk-6u14-linux-i586.bin
3. 安装 在当前路径,./jdk-6u14-linux-i586.bin;一路确定,装好之后在同一目录下会生成一个文件夹,jdk1.6.0_14,里边是一些lib等文件,同windows下生成的安装文件夹一样。
4.设 ......
class Tank{
int level;
}
public class Assignment {
public static void main(String[] args) {
Tank t1 = new Tank();
Tank t2 = new Tank();
t1.level= 9;
t2.level= 47;
System.out.println("1:t1.l ......