java 打开文件
2013-07-18 21:20
218 查看
windows系统提供了一个叫Rundll32.exe的文件,顾名思义,它的作用是执行DLL文件中的内部函数,这样在进程当中,只会有rundll32.exe,而不会有DLL后门的进程,这样,就实现了进程上的隐藏。rundll32.exe的具体使用方法如下:
Rundll32.exe DLLname,Functionname [Arguments]
DLLname为需要执行的DLL文件名;Functionname为前边需要执行的DLL文件的具体引出函数;[Arguments]为引出函数的具体参数。
结合url.dll和rundll32.exe,我们就可以通过在命令行中启动相应程序打开相应文档: 假设我有一个pdf文档,存放在c:\test.pdf 。打开命令行, 运行如下 命令:
rundll32 url.dll FileProtocolHandler
下面是通过JFileChoose对话框,选中一个文件之后,打开所选的文件,像直接双击打开文件一样的,打开选中的文件
Rundll32.exe DLLname,Functionname [Arguments]
DLLname为需要执行的DLL文件名;Functionname为前边需要执行的DLL文件的具体引出函数;[Arguments]为引出函数的具体参数。
结合url.dll和rundll32.exe,我们就可以通过在命令行中启动相应程序打开相应文档: 假设我有一个pdf文档,存放在c:\test.pdf 。打开命令行, 运行如下 命令:
rundll32 url.dll FileProtocolHandler
下面是通过JFileChoose对话框,选中一个文件之后,打开所选的文件,像直接双击打开文件一样的,打开选中的文件
JFileChooser chooseFile = new JFileChooser(); FileFilter filter = new FileFilter() { //要过滤的文件 public boolean accept(File f) { //显示的文件类型 if (f.isDirectory()) { return true; } //显示满足条件的文件 return f.getName().endsWith(".txt") || f.getName().endsWith(".java"); } /** * 这就是显示在打开框中 */ public String getDescription() { return "*.txt,*.java"; } }; FileFilter filter1 = new FileFilter() { public boolean accept(File f) { if (f.isFile()) { return true; } //显示满足条件的文件 return f.getName().endsWith(".xls"); } /** * 这就是显示在打开框中 */ public String getDescription() { return "*.xls"; } }; chooseFile.addChoosableFileFilter(filter); chooseFile.addChoosableFileFilter(filter1); int open = chooseFile.showOpenDialog(this); if (open == JFileChooser.APPROVE_OPTION) { File f = chooseFile.getSelectedFile(); Runtime runtime = Runtime.getRuntime(); try{ System.out.println(f.getAbsolutePath()); //打开文件 runtime.exec("rundll32 url.dll FileProtocolHandler "+f.getAbsolutePath()); }catch(Exception ex){ ex.printStackTrace(); } }
相关文章推荐
- Java打开本地文件/exe/打开网址/调用cmd
- Java基础学习之io流的练习(NotePad的打开文件和保存文件)
- 防浏览器直接打开文件的java下载
- intellij打开工程在每个java文件上有个红色的无效符的解决办法
- java 打开本地word等文件
- java 直接打开pdf文件
- java解决指定应用程序打开指定文件
- java 语言运行exe或者直接打开文件(Windows下)
- Java调用本机程序完成打开网页、发送邮件和编辑文件
- Eclipse直接打开java文件在计算机中的目录
- 未公开的mustang核心秘密(五): java判断文件类型和文件打开
- Java直接打开文件或超链接
- 用java打开一个本地文件的方法
- 如何双击打开JAVA中的jar文件(类似于VC中的可执行文件)
- [置顶] java语言编程实现打开exe可执行文件以及txt,word等文件功能
- java打开文件的代码
- JAVA GUI(菜单-打开文件-保存文件)
- java 直接打开pdf文件
- 用java打开电脑上的文件
- 用JAVA打开一个已经写好的TXT文件