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
相关文档:
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import jxl.Workbook;
import jxl.format.Alignment;
import jxl.format.Border;
import jxl.format.BorderLineStyle;
......
第一种DES加密算法
import java.security.Key;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
/**
*
* 使用DES加密与解密,可对byte[],String类型进行加密与解密 密文可使用 ......
转载自:http://blog.csdn.net/ilibaba/archive/2009/03/07/3965359.aspx
被架构师问的面试题
1. 异常机制
异常机制是指当程序出现错误后,程序如何处理。具体来说,异常机制提供了程序退出的安全通道。当出现错误后,程序执行的流程发生改变,程序的控制权转移到异常处理器。
......