diff --git a/DGcreate/.idea/inspectionProfiles/Project_Default.xml b/DGcreate/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..801f533 --- /dev/null +++ b/DGcreate/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/DGcreate/.idea/uiDesigner.xml b/DGcreate/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/DGcreate/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DGcreate/.idea/vcs.xml b/DGcreate/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/DGcreate/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/DGcreate/out/production/DGcreate/joggle/joggle.class b/DGcreate/out/production/DGcreate/joggle/joggle.class new file mode 100644 index 0000000..39434e3 Binary files /dev/null and b/DGcreate/out/production/DGcreate/joggle/joggle.class differ diff --git a/DGcreate/out/production/DGcreate/menu/Main$1.class b/DGcreate/out/production/DGcreate/menu/Main$1.class new file mode 100644 index 0000000..8ed4429 Binary files /dev/null and b/DGcreate/out/production/DGcreate/menu/Main$1.class differ diff --git a/DGcreate/out/production/DGcreate/menu/Main$2.class b/DGcreate/out/production/DGcreate/menu/Main$2.class new file mode 100644 index 0000000..d527897 Binary files /dev/null and b/DGcreate/out/production/DGcreate/menu/Main$2.class differ diff --git a/DGcreate/out/production/DGcreate/menu/Main.class b/DGcreate/out/production/DGcreate/menu/Main.class new file mode 100644 index 0000000..1419b67 Binary files /dev/null and b/DGcreate/out/production/DGcreate/menu/Main.class differ diff --git a/DGcreate/src/joggle/joggle.java b/DGcreate/src/joggle/joggle.java new file mode 100644 index 0000000..eacaaa0 --- /dev/null +++ b/DGcreate/src/joggle/joggle.java @@ -0,0 +1,39 @@ +package joggle; +import javax.swing.*; +import java.awt.Desktop; +import java.io.*; + +public class joggle { + public static boolean open_resource(){ + JFileChooser fd = new JFileChooser(); + //fd.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + fd.showOpenDialog(null); + File f = fd.getSelectedFile(); + if(f != null){} + return true; + } + public static void copyFile(String oldPath, String newPath) { + try { + int bytesum = 0; + int byteread = 0; + File oldfile = new File(oldPath); + if (oldfile.exists()) { // 文件存在时 + InputStream inStream = new FileInputStream(oldPath); // 读入原文件 + FileOutputStream fs = new FileOutputStream(newPath); + byte[] buffer = new byte[1444]; + int length; + while ((byteread = inStream.read(buffer)) != -1) { + bytesum += byteread; // 字节数 文件大小 + System.out.println(bytesum); + fs.write(buffer, 0, byteread); + } + inStream.close(); + } + } catch (Exception e) { + System.out.println("复制单个文件操作出错"); + e.printStackTrace(); + } + } +} + + diff --git a/DGcreate/src/menu/Main.java b/DGcreate/src/menu/Main.java index 996efb1..682040b 100644 --- a/DGcreate/src/menu/Main.java +++ b/DGcreate/src/menu/Main.java @@ -3,6 +3,9 @@ package menu; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; +import joggle.joggle; +import java.io.*; + //主窗口 public class Main extends menu { @@ -28,9 +31,9 @@ public class Main extends menu { b.setVisible(true); //鼠标触发事件 b.addActionListener(new AbstractAction() { - @Override public void actionPerformed(ActionEvent e) { - System.out.println("Hello World");// 控制台打印输出 + joggle.open_resource(); + JFileChooser fd = new JFileChooser(); } }); } @@ -47,7 +50,8 @@ public class Main extends menu { b.addActionListener(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { - System.out.println("打开");// 控制台打印输出 + joggle.open_resource(); + joggle.copyFile("C:/Users/wangw/Desktop/英语作文","C:/Users/wangw/Desktop/英语作文"); } }); }