用jsp File browser,
http://www.vonloesch.de/jspbrowser.html
解决方案 »
- request.getSession().setAttribute不能传递反斜杠“\"?
- java代码如何读取UKEY的信息呢?
- 刚开始学习struts就遇到问题了,很是困惑!
- 关于自动登录网站,并查询
- 请教一个文件上传下载的问题
- !!!!!!!!!!请教关于InstallShield Developer 8的设置路经问题!紧急,可立即结分!谢谢。!!!!!!!!!!
- 有关jsp页面中利用activex下载、更新安装程序的问题
- 问几个初级问题,刚学jsp
- 请教几个弱弱的送分问题。
- tapestry5的textfield标签显示double类型会四舍五入???
- 问一个获得字符的问题,很晕哦!
- 关于readline的怪问题
{
public DeliveryUtil()
{
} public static final String OctalHexNoZero = "(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[1-9])";
public static final String OctalHex = "(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])"; /**
* Copy file to another place.
* @param sourceFilePath String
* @param destFilePath String
*/
private static boolean CopyFile(String sourceFilePath, String destFilePath)
{
File sourceFile = new File(sourceFilePath);
BufferedInputStream fin = null;
BufferedOutputStream fout = null; try
{
fin = new BufferedInputStream(new FileInputStream(sourceFile));
fout = new BufferedOutputStream(new FileOutputStream(destFilePath));
byte[] b = new byte[1024];
int len = 0;
while ( (len = fin.read(b)) != -1)
{
fout.write(b, 0, len);
}
}
catch (IOException ex)
{
ex.printStackTrace();
return false;
}
finally
{
try
{
fin.close();
fout.close();
}
catch (IOException ex)
{
return false;
}
}
return true;
} /**
* Copy file to another place.
* @param sourceFilePath String
* @param destFilePath String
* @throws IOException
*/
public static boolean XCopyDir(String sourceDir, String destDir)
{
File source = new File(sourceDir);
File dest = new File(destDir); if(!source.isDirectory())
{
throw new IllegalArgumentException("invalid source directory path,path="+sourceDir);
}
if(!dest.exists()&&!dest.mkdirs())
{
UspLog.error("create dir error,dir="+dest);
return false;
}
File[] files = source.listFiles();
String destPath = null;
for(int i=0;i<files.length;i++)
{
destPath = destDir+"\\"+files[i].getName();
boolean isExists = new File(destPath).exists();
if(files[i].isFile()&&!isExists)
{
if(!CopyFile(files[i].getPath(), destPath))
{
UspLog.error("copy file error,file="+files[i].getPath()+",destpath="+destPath);
return false;
}
}
else if(files[i].isDirectory()&&!isExists)
{
if(!XCopyDir(files[i].getPath(),destPath))
return false;
}
}
return true;
} /**
* Copy file to another place.
* @param sourceFilePath String
* @param destFilePath String
* @throws IOException
*/
private static boolean XCopyDirWithCMD(String sourceDirPath, String destDirPath)
{ String command = "xcopy " + sourceDirPath + " " + destDirPath + " /e /s /i";
try
{
Process proc = Runtime.getRuntime().exec(command);
/* Causes the current thread to wait, if necessary,
until the process represented by this Process object has terminated.
*/ if (proc.waitFor() != 0)
{
// Return the exit value for the process,the value 0 indicates normal
// termination. if ( (proc.exitValue()) != 0)
{
return false;
}
}
}
catch (Exception ex)
{
return false;
}
return true;
} private static boolean DeleteFile(String filePath)
{
File file = new File(filePath);
if (file.exists())
{
return file.delete();
}
else
{
return false;
}
} public static boolean XDeleteDir(String dirPath)
{
File dir = new File(dirPath);
if(!dir.isDirectory())
{
return false;
}
File[] files = dir.listFiles(); for(int i=0;i<files.length;i++)
{
if(files[i].isFile())
{
if(!files[i].delete())
{
UspLog.error("delete file error,file="+files[i]);
return false;
}
}
else if(files[i].isDirectory())
{
if(!XDeleteDir(files[i].getPath()))
return false;
}
}
return dir.delete();
}
}