/**
* @Title: outXmlFile
* @Description: TODO(生成一个xml文件,保存到本地)
* @param @throws FileNotFoundException 设定文件
* @return void 返回类型
* @throws
* @author 王明雨
* @date 2013-3-21 下午05:21:02
*/
public static void outFile(String filePath,String type,String fileName,String content) throws FileNotFoundException{
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
//创建不同目录名地址
String[] file=filePath.split("/");
String fpath="";
//根据文件根目录创建 当前日期的文件目录
// 循环读取路径 没有目录 则进行创建
for(int i=0;i<file.length;i++){
fpath+=file[i]+"/";
File f=new File(fpath);
f.mkdir();
}
//创建输出对象
PrintWriter pw=new PrintWriter(path+fileName);
//添加输出内容
pw.write(content);
pw.close();
}
/**
* @Title: getFileName
* @Description: TODO(根据传入的表头名 返回一个文件名
* 规则 fileName+时分秒[HHmmss])
* @param @param fileName
* @param @return 设定文件
* @return String 返回类型
* @throws
* @author 王明雨
* @date 2013-3-21 下午06:21:32
*/
public static String getFileName(String fileName){
SimpleDateFormat dfsfm = new SimpleDateFormat("HHmmss");
//文件命名规则: 传入的文件名+ 当前时分秒
//文件名
String file=fileName+"_"+dfsfm.format(new Date())+".xml";
return file;
}
* @Title: outXmlFile
* @Description: TODO(生成一个xml文件,保存到本地)
* @param @throws FileNotFoundException 设定文件
* @return void 返回类型
* @throws
* @author 王明雨
* @date 2013-3-21 下午05:21:02
*/
public static void outFile(String filePath,String type,String fileName,String content) throws FileNotFoundException{
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
//创建不同目录名地址
String[] file=filePath.split("/");
String fpath="";
//根据文件根目录创建 当前日期的文件目录
// 循环读取路径 没有目录 则进行创建
for(int i=0;i<file.length;i++){
fpath+=file[i]+"/";
File f=new File(fpath);
f.mkdir();
}
//创建输出对象
PrintWriter pw=new PrintWriter(path+fileName);
//添加输出内容
pw.write(content);
pw.close();
}
/**
* @Title: getFileName
* @Description: TODO(根据传入的表头名 返回一个文件名
* 规则 fileName+时分秒[HHmmss])
* @param @param fileName
* @param @return 设定文件
* @return String 返回类型
* @throws
* @author 王明雨
* @date 2013-3-21 下午06:21:32
*/
public static String getFileName(String fileName){
SimpleDateFormat dfsfm = new SimpleDateFormat("HHmmss");
//文件命名规则: 传入的文件名+ 当前时分秒
//文件名
String file=fileName+"_"+dfsfm.format(new Date())+".xml";
return file;
}