これは私の実際の移動コードです:
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 を移動したい
~/Application support\minecraft/bin/minecraft.jar へ (.jar はフォルダーに解凍されます)