-4
textbox
에 문제가 있습니다. arraylist 내부의 파일을 복사하여 다른 폴더로 전송하려고합니다. 내부 String strSource = "D:\\New folder\\";
String strDestination = "D:\\New folder\\Another Folder\\";
자바의 텍스트 상자에서 문자열을 가져 오는 방법
그것은 복사 파일을하지만 난 대상으로 String strSource = txtSource.getText();
로 변경하고 같은 경우이 오류입니다 만 catch
하지만 대상 폴더가 비어 :
것은 나는 이것을 사용하고합니다. 너희들이 내 질문에 혼란 스러울 때 나는 너에게 설명하려고 노력할 것이다.
복사 방법
public void copyFiles(String source, String destination){
try {
File fileFrom = new File(source);
File fileTo = new File(destination);
Files.copy(fileFrom.toPath(), fileTo.toPath());
} catch (IOException e) {
// e.printStackTrace();
MessageBox msgBox = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
msgBox.setText("Error");
msgBox.setMessage("File is AlreadyExist."); //where this is the one catching..
msgBox.open();
}
}
복사 버튼
String strSource = new String(txtSource.getText());
String strDestination = new String (txtDestination.getText());
try {
ArrayList<String> list = readConfigFileList(ConstantVariables.SPECIFIC_FILE_LIST);
for (String strList : list) {
copyFiles(strSource + strList, strDestination + strList);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
하십시오 [편집] 전체 스택 트레이스를 포함하는 질문은 (확률은 이미 문제가 무엇인지를 알려하려고하는 것이 좋다). 또한, [mcve]를 제공하십시오. 파일 복사 코드가 작동한다고 언급 했으므로 "최소 예제"는 아마도 "getText'에 의해 반환 된 예기치 않은 문자열을 출력합니다. –
@ KevinJ.Chase 제 질문에 대한 답변은 이미 나 자신이하고 있습니다. 내 대답을 게시해야합니까? –