zl程序教程

您现在的位置是:首页 >  后端

当前栏目

java 打开文件夹

JAVA 打开 文件夹
2023-09-14 08:59:46 时间
    public static void open_directory(String folder) {           File file = new File(folder);           if (!file.exists()) {               return;           }           Runtime runtime = null;           try {               runtime = Runtime.getRuntime();               if (!SystemUtil.isWindows) {                   // System.out.println("is linux");                   runtime.exec("nautilus " + folder);               } else {                   runtime.exec("cmd /c start explorer " + folder);               }           } catch (IOException ex) {               ex.printStackTrace();           } finally {               if (null != runtime) {                   runtime.runFinalization();               }           }       }  
    public static void open_file(String filePath) {           File file = new File(filePath);           if (!file.exists()) {               return;           }           Runtime runtime = null;           try {               runtime = Runtime.getRuntime();               if (!SystemUtil.isWindows) {                   // System.out.println("is linux");                   runtime.exec("nautilus " + filePath);               } else {                   runtime.exec("cmd /c start explorer /select,/e, " + filePath);               }           } catch (IOException ex) {               ex.printStackTrace();           } finally {               if (null != runtime) {                   runtime.runFinalization();               }           }       }  
openFileButton.addActionListener(new ActionListener() {               public void actionPerformed(ActionEvent e) {                   FileUtils.open_file(sourceTF.getText());                               }           });   openFolderButton = new JButton("打开文件夹");           openFolderButton.addActionListener(new ActionListener() {               public void actionPerformed(ActionEvent e) {                   //打开文件夹                   FileUtils.open_directory(targetTF.getText());               }           });  
Java实战:指定大小分组压缩文件夹里面的文件案例 今天给大家分享一个自己写的java实战的小案例,主要功能是实现指定一个文件夹,然后分组压缩里面的文件。其实这个案例还是有一定用途的,比如日志文件夹里面有几千个文件,如果我需要给每个压缩包指定10M,把整个文件夹里面的日志文件都进行压缩,这个案例就能够用得上了。
java下载多文件夹的文件最终打zip包返回给用户 业务需求,需要做一个导出用户单据图片的功能,需求为:按单据单号分文件夹分别存储单据的图片!最终导出zip包给用户。通过网上各种找代码,写出一个小demo,供各位看官学习! // 假装是一个单据集合 List String imgUrls = new ArrayList (); imgUrls.
闲来无事,java写入文件后,利用bat文件建立大量文件夹 今天看到了一个写.bat文件来快捷建立文件夹的小代码 “md 文件夹名字”如图:将.txt文件后缀名改为.bat双击执行,就可以完成一个文件夹的建立,如图: 试了一下,我就发现当有巨大量的文件夹时候,如果一个一个的去敲就不太方便了,于是就利用java将字符串写入文件中,利用一个for循环,想加多少...
Java的库中没有提供直接的删除文件夹及其子文件的方法,需要自己写,下面提供两种删除方式。
黄威的世界 我是一个热衷IT技术的人,希望自己不断地设计开发出对别人非常有用的软件。有近7年的java开发经验(包括2年Android开发经验)和一年左右的linux使用经验。擅长Java Web后台开发 ,喜欢研究新的各种实用技术