이 코드를 사용하여 폴더를 이동 한 다음 원래 대상으로 하드 링크합니다. 문제는 완전히 일식 때 그것을 노력하고 있지만 그것을 만들 때 자신의 자기 실행 항아리 하드 링크를 만들지 않을 것이지만 폴더를 이동합니다. 이 코드는 명령 행을 실행 한 다음 명령을 입력합니다. 나는 이동 명령이 작동하는지 다른 하나가 아닌지 잘 모른다. 도와주세요. (Mklink 명령)은 기본적으로 실행할 때 프로그램이 mklink 명령을 실행하려고 시도하기 전에, 이동 명령이 완료되지 않은Java에서 CMD 명령 실행
import java.io.*;
import javax.swing.JOptionPane;
public class The_Cloud_Setup {
public static void main(String[] args) throws IOException
{
try {
String command = "c:\\cmd.exe";
Runtime.getRuntime().exec(command);
}
catch (IOException e){
JOptionPane.showMessageDialog(null , e.getMessage(), "End Result", 2);
System.err.println(e.getMessage());
}
String[] StringMove = { "cmd.exe", "/c", "move"+" "+"\"C:/Users/%username%/Documents/My Games/Terraria/Players\""+" "+"\"C:/Users/%username%/Google Drive/Players\""};
String[] StringMklink = {"cmd.exe", "/c", "mklink"+" "+"/d"+" "+"\"C:/Users/%username%/Documents/My Games/Terraria/Players\""+" "+"\"C:/Users/%username%/Google Drive/Players\""};
Process ProcessMove = Runtime.getRuntime().exec(StringMove);
Process ProcessMklink = Runtime.getRuntime().exec(StringMklink);
BufferedReader VarMove = new BufferedReader(new InputStreamReader(ProcessMove.getInputStream()));
BufferedReader VarMklink = new BufferedReader(new InputStreamReader(ProcessMklink.getInputStream()));
String temp = "";
while ((temp = VarMove.readLine()) != null) {
System.out.println(temp);
}
VarMove.close();
VarMklink.close();
}
}
Java 규약에 따라 변수 이름을 소문자로 시작해야합니다. –