资源简介
jsp编辑器很好用的 本人经过测试!jsp在线编辑器
代码片段和文件信息
package com.vsked.fileoperate;
/*
* To change this template choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author 非灭天
*/
import java.io.*;
public class CreateFileUtil {
/**
* 创建文件
* @param destFileName 文件名称
* @return
*/
public static boolean CreateFile(String destFileName) {
File file = new File(destFileName);
if (file.exists()) {
System.out.println(“创建单个文件“ + destFileName + “失败,目标文件已存在!“);
return false;
}
if (destFileName.endsWith(File.separator)) {
System.out.println(“创建单个文件“ + destFileName + “失败,目标不能是目录!“);
return false;
}
if (!file.getParentFile().exists()) {
// System.out.println(“目标文件所在路径不存在,准备创建。。。“);
if (!file.getParentFile().mkdirs()) {
// System.out.println(“创建目录文件所在的目录失败!“);
return false;
}
}
// 创建目标文件
try {
if (file.createNewFile()) {
// System.out.println(“创建单个文件“ + destFileName + “成功!“);
return true;
} else {
System.out.println(“创建单个文件“ + destFileName + “失败!“);
return false;
}
} catch (IOException e) {
e.printStackTrace();
System.out.println(“创建单个文件“ + destFileName + “失败!“);
return false;
}
}//end method create method
/**
* 创建目录
* @param destDirName 目录名称
* @return boolean
*/
public static boolean createDir(String destDirName) {
File dir = new File(destDirName);
if (dir.exists()) {
System.out.println(“创建目录“ + destDirName + “失败,目标目录已存在!“);
return false;
}
if (!destDirName.endsWith(File.separator)) {
destDirName = destDirName + File.separator;
}
// 创建单个目录
if (dir.mkdirs()) {
// System.out.println(“创建目录“ + destDirName + “成功!“);
return true;
} else {
// System.out.println(“创建目录“ + destDirName + “成功!“);
return false;
}
}//end method createDir
/**
* 3*. 从输入流中拷贝内容到输入流中
* @throws IOException
*/
public void copyStream(InputStream is OutputStream os) {
try {
// 这个读过过程可以参阅 readToBuffer 中的注释
String line;
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
PrintWriter writer = new PrintWriter(new OutputStreamWriter(os));
line = reader.readLine();
while (line != null) {
writer.println(line);
line = reader.readLine();
}
writer.flush(); // 最后确定要把输出流中的东西都写出去了
} catch (Exception e) {
e.printStackTrace();
}
}//end copyStream method
/**
* 复制文件
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
I.A.... 440 2010-07-04 11:48 JspSinaEditor\.classpath
I.A.... 312 2010-07-04 11:08 JspSinaEditor\.myme
I.A.... 1419 2010-06-28 11:27 JspSinaEditor\.project
I.A.... 500 2010-06-28 11:23 JspSinaEditor\.settings\.jsdtscope
I.A.... 49 2010-06-28 11:23 JspSinaEditor\.settings\org.eclipse.wst.jsdt.ui.superType.container
I.A.... 6 2010-06-28 11:23 JspSinaEditor\.settings\org.eclipse.wst.jsdt.ui.superType.name
I.A.... 4252 2010-06-20 00:43 JspSinaEditor\src\com\vsked\fileoperate\CreateFileUtil.java
I.A.... 1056 2009-06-27 12:47 JspSinaEditor\src\com\vsked\fileoperate\FilesOperate.java
I.A.... 1914 2010-06-19 15:17 JspSinaEditor\src\com\vsked\fileoperate\TestFile.java
I.A.... 635 2010-06-28 12:15 JspSinaEditor\WebRoot\index.jsp
I.A.... 39 2010-06-28 11:23 JspSinaEditor\WebRoot\me
I.A.... 278 2010-07-04 12:22 JspSinaEditor\WebRoot\readme.txt
I.A.... 709 2010-06-28 11:32 JspSinaEditor\WebRoot\receveData.jsp
I.A.... 4263 2010-07-04 12:09 JspSinaEditor\WebRoot\sinaEditor\Edit\editor\attach.htm
I.A.... 2912 2010-06-28 11:24 JspSinaEditor\WebRoot\sinaEditor\Edit\editor\ba
I.A.... 47654 2010-06-28 11:24 JspSinaEditor\WebRoot\sinaEditor\Edit\editor\editor.js
I.A.... 4160 2010-07-04 12:09 JspSinaEditor\WebRoot\sinaEditor\Edit\editor\img.htm
I.A.... 3219 2010-06-28 11:24 JspSinaEditor\WebRoot\sinaEditor\Edit\editor\li
I.A.... 4595 2010-06-28 11:24 JspSinaEditor\WebRoot\sinaEditor\Edit\editor\table.htm
I.A.... 3121 2010-07-04 12:19 JspSinaEditor\WebRoot\sinaEditor\Edit\editor\upload.jsp
I.A.... 3954 2010-06-28 11:24 JspSinaEditor\WebRoot\sinaEditor\Edit\editor.htm
I.A.... 887 2010-06-28 11:24 JspSinaEditor\WebRoot\sinaEditor\Edit\face\001.gif
I.A.... 2225 2010-06-28 11:24 JspSinaEditor\WebRoot\sinaEditor\Edit\face\002.gif
I.A.... 1498 2010-06-28 11:24 JspSinaEditor\WebRoot\sinaEditor\Edit\face\003.gif
I.A.... 1022 2010-06-28 11:24 JspSinaEditor\WebRoot\sinaEditor\Edit\face\004.gif
I.A.... 818 2010-06-28 11:24 JspSinaEditor\WebRoot\sinaEditor\Edit\face\005.gif
I.A.... 856 2010-06-28 11:24 JspSinaEditor\WebRoot\sinaEditor\Edit\face\006.gif
I.A.... 1153 2010-06-28 11:24 JspSinaEditor\WebRoot\sinaEditor\Edit\face\007.gif
I.A.... 1202 2010-06-28 11:24 JspSinaEditor\WebRoot\sinaEditor\Edit\face\008.gif
I.A.... 1028 2010-06-28 11:24 JspSinaEditor\WebRoot\sinaEditor\Edit\face\009.gif
............此处省略148个文件信息
评论
共有 条评论