最近在做仿百度在线阅读的项目,上网查了一下方法,做的时候遇到一个问题,一直不知道怎么解决,swftools将pdf转换为swf成功了,但是在写到磁盘的时候出问题了,无论怎么搞就是写不到部署项目的根目录(便于jsp页面调用展示),别的盘都没问题。代码如下:
Process p = Runtime.getRuntime().exec("D:/Program Files/SWFTools/pdf2swf.exe "
+ pdfFile.getPath() + " -o " + swfFile.getPath()
+ " -T 9"); //执行命令
BufferedReader bufferedReader = new BufferedReader(
new InputStreamReader(p.getInputStream()));
while (bufferedReader.readLine() != null);
try {
p.waitFor();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
多谢!
1、软链接;
linux 使用 ln
window 请参考:
[url]http://sishuok.com/forum/posts/list/0/5672.html[/url]
如把web应用/download 文件夹 软连接到 D:\aa 这样比较可靠(否则一不小心覆盖了web应用 你的东西全没了)
2、在项目中通过配置文件指定pdf写出的位置
这个路径应该可以帮到你:
String realContenxtPath = request.getSession().getServletContext()
.getRealPath("/");