try (InputStream inputStream = new FileInputStream(sourceText); OutputStream outputStream = new FileOutputStream(destinationText)) { byte[] buffer = new byte[1024]; int bytesRead; while ((bytesRead = inputStream.read(buffer)) != -1) { outputStream.write(buffer, 0, bytesRead); } JOptionPane.showMessageDialog(this, "File copied successfully."); } catch (IOException e) { JOptionPane.showMessageDialog(this, "An error occurred while copying the file."); }

import javaawt;import javaawtevent;import javaxswing;import javaio;public class FileCopyApplication extends JFrame implements ActionListener private JTextArea sourceTextArea; private JTextArea

原文地址: https://www.cveoy.top/t/topic/iaGz 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录