这是我的实际移动代码:
import java.awt.Component;
import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
public class CopyFileMac {
public void COPY(){
final JFileChooser fc = new JFileChooser();
Component aComponent = null;
int returnVal = fc.showOpenDialog(aComponent);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
}
else
{
JOptionPane.showMessageDialog(null, "You Selected Cancel");
System.exit(0);
}
}
}
这是我的演示:
import javax.swing.*;
public class FileMover {
/**
* @param args
*/
public static void main(String[] args) {
CopyFilePc CopyFilePc = new CopyFilePc();
CopyFileMac CopyFileMac = new CopyFileMac();
String MacOrPc;
MacOrPc = JOptionPane.showInputDialog(null, "Do you have a Mac or PC?");
if (MacOrPc.equalsIgnoreCase("mac"))
{
CopyFileMac.COPY();
}
if (MacOrPc.equals("pc"))
{
CopyFilePc.COPY();
}
我想移动〜/ Downloads / FILE
To~ / Application support \ minecraft / bin / minecraft.jar(.jar将解压缩到一个文件夹中)