Java常用代码
/**
* 创建一个新的文件
* @param relativePath 相对路径
* @param fileName 文件名
* @return
* @throws IOException
*/
public File createFile(String relativePath, String fileName) throws IOException {
String upPath = getFileUploadPath() + relativePath + "\\";
System.out.println("upPath:" + upPath);/////////////////////////////
System.out.println("fileName:" + fileName);/////////////////////////////
String nameWithoutExt = getNameWithoutExtension(fileName);
String ext = getExtension(fileName);
createDirectory(upPath);// 上传目录不存在则创建目录
File newFile = new File(upPath + fileName);
// 若有重名文件则修改名称创建新的文件
for (int counter = 1; newFile.exists(); counter ++) {
fileName = nameWithoutExt + "(" + String.valueOf(counter) + ")." + ext;
newFile = new File(upPath + fileName);
}
newFile.createNewFile();
return newFile;
}
=================================================================================
/**
* 文件的写入 (单行写入)
* @param filePath(文件路径)
* @param fileName(文件名)
* @param args
* @throws IOException
*/
public void writeF
相关文档:
//java.io
---------------------------------------------------------------
/**
* Title: 文件的各种操作
* Copyright: Copyright (c) 2004
* Company: 广东 有限公司
* @author 网络信息部 庆丰
* @version 1.0
*/
p ......
树是一个递归的数据结构,一棵树上的所有节点都可以被看成是一棵树,只不过除根节点外其他节点都比总树的规模小点而已。树的节点有三种:根节点(没有父亲节点),叶子节点(没有孩子节点),一般节点(既有父亲节点,也有孩子节点)。具体对结构的分析,几乎所有写数据结构的书中都有提到。
这棵树的实现花了好几天时间, ......
一. 什么是Native Method
简单地讲,一个Native Method就是一个java调用非java代码的接口。一个Native Method是这样一个java的方法:该方法的实现由非java语言实现,比如C。这个特征并非java所特有,很多其它的编程语言都有这一机制,比如在C++中,你可以用extern "C"告知C++编译器去调用一个C的函 ......
到http://download.csdn.net/source/1781433下载jxl.jar文件
/*Title是保存出来的文件名,gbl_LastOpenPath用于记录上次打开的路径*/
public void ExportToExcel(JTable table, String Title){
File DefaultFile;
JFileChooser fc = new JFileChooser();
File file;
if(gbl_LastOpen ......
枚举类型是JDK5.0的新特征。Sun引进了一个全新的关键字enum来定义一个枚举类。下面就是一个典型枚举类型的定义:
Java代码
public enum Color{
RED,BLUE,BLACK,YELLOW,GREEN
}
public enum Color{
RED,BLUE,BLACK,YELLOW,GREEN
}
显 ......