zoukankan      html  css  js  c++  java
  • java 新建文件夹保存

    String Txtname = field.getText();
                    File file3 =new File("D:\MATP_robot"+"\"+ Txtname);    
                    //如果文件夹不存在则创建    
                    if  (!file3 .exists()  && !file3 .isDirectory())      
                    {       
                        System.out.println("//不存在");  
                        file3 .mkdir();    
                    } else   
                    {  
                        System.out.println("//目录存在");  
                    }  

                    File file = new File(".\config\batfolder\Matp.bat");
                    if (file.exists()) {
                        file.delete();
                    }
                    BufferedWriter writer = null;

                    try {
                        writer = new BufferedWriter(new FileWriter(
                                ".\config\batfolder\Save.bat", true));
                    } catch (IOException e2) {
                        // TODO Auto-generated catch block
                        e2.printStackTrace();
                    }

                    try {
                        writer.write("echo off" + " ");
                        writer.write("copy .\config\shutter_button.txt "+ "D:\MATP_robot"+"\"+Txtname
                                + " ");

                        writer.flush();
                        writer.close();
                    } catch (IOException e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                    }
                    
                    RAMThreadOn mRAMThreadOn = new RAMThreadOn();
                    mRAMThreadOn.run();
                    String Txtname2 = field2.getText();
                    File f = new File("D:\MATP_robot\"+"\"+Txtname+"\"+"shutter_button.txt");
                    System.out.println(f);
                    f.renameTo(new File("D:\MATP_robot\" + "\"+Txtname+"\" + Txtname2 + ".txt"));
                    System.out.println(f + "========11========");
                    JOptionPane.showMessageDialog(null, "脚本保存在D:\MATP_robot"+"\"+Txtname+"目录中");
                    field2.setText("");
                    
                }
                field.selectAll();
                // 隐藏对话框
                setVisible(false);

  • 相关阅读:
    attr方法笔记(反射)
    微信小程序的view标签中text如何居中?
    如何在button里面插入图片?
    html如何实现空格?
    margin-left有效果但是margin-top没有用没有效果?如何解决?
    html里button实现跳转事件
    js 字符串切割
    html获取输入框的值
    Uncaught TypeError: Cannot read property ‘split’ of undefined
    日历实现
  • 原文地址:https://www.cnblogs.com/dreamy890322/p/4478389.html
Copyright © 2011-2022 走看看