jFileChooser 내부에서 선택된 파일을 stringbuilder 세그먼트의 문자열로 설정하려고하지만 특정 패턴으로 설정하려고합니다. 나는.jFileChooser에서 선택한 파일을 문자열로 설정 하시겠습니까?
{
sb.append(" -file").append(mods);
}
는 AND "개조"는 파일이며, 각각의 파일 사이에, 예를 들어 "- 파일"이고 I는 file2.wad 및 file3.pk3 프로그램에 다음 원하는 출력을 선택하는 경우 file1.wad 그러면
-file file1.wad -file file2.wad -file file3.pk3
어떻게하면됩니까?
수정 여기 내 코드가 더 있습니다. 파코 아바 토 (Paco Abato)가 제안한 코드는 어디에서 나왔습니까? 왜냐하면 코드의 맨 아래에 많은 오류가 발생하기 때문입니다.
private void RunGameButtonActionPerformed(java.awt.event.ActionEvent evt) {
String PlayerCount = PlayerCountHere.getText();
String HostIP = HostIPHere.getText();
//String MapWarp = MapWarpBox.getName();
try
{
//Basic game launching command.
StringBuilder sb = new StringBuilder("cmd.exe /C start C:\\mygame\\game.exe");
if(NoMonstersBox.isSelected())
{
//Add the No Monsters Flag
sb.append(" -nomonsters");
}
if(CheatsBox.isSelected())
{
//Add the Cheats Flag
sb.append(" +SV_CHEATS 1");
}
if(Netmode0Button.isSelected())
{
//Add Netmode 0 Flag
sb.append(" -netmode 0");
}
if(Netmode1Button.isSelected())
{
//Add Netmode 1 Flag
sb.append(" -netmode 1");
}
if(DeathmatchButton.isSelected())
{
//Add the Deathmatch Flag
sb.append(" -deathmatch");
}
if(CoopButton.isSelected())
{
//Add the Co-op Flag
sb.append(" -coop");
}
if(Skill1Button.isSelected())
{
//Add the Skill 1 Flag
sb.append(" -skill 1");
}
if(Skill2Button.isSelected())
{
//Add the Skill 2 Flag
sb.append(" -skill 2");
}
if(Skill3Button.isSelected())
{
//Add the Skill 3 Flag
sb.append(" -skill 3");
}
if(Skill4Button.isSelected())
{
//Add the Skill 4 Flag
sb.append(" -skill 4");
}
if(Skill5Button.isSelected())
{
//Add the Skill 5 Flag
sb.append(" -skill 5");
}
if(HostButton.isSelected())
{
//Add the Host Flag and add the Player Count from the box
sb.append(" -host ").append(PlayerCount);
}
if(JoinButton.isSelected())
{
//Add the Join Flag and add the Host IP from the box
sb.append(" -join ").append(HostIP);
}
//Launch the game
Process process = Runtime.getRuntime().exec(sb.toString());
}
catch(IOException e)
{
//Log Error
}
}
으로 반복 당신이 선택하고, 'file.path()'(정규/절대/...) 또는 추가 'file.name를 추가하거나() ' 이것은 올바른 코드가 아니며 단지 아이디어를 제공하기위한 것입니다. – Stultuske