如何在java中从文本框中获取字符串

如何在java中从文本框中获取字符串,java,swt,Java,Swt,我的文本框有问题。我正在尝试复制arraylist中的文件并将其传输到另一个文件夹 当我使用以下命令时:String strSource=“D:\\New folder\\” String strDestination=“D:\\New folder\\other folder\\” 它在内部复制文件,但当我将其更改为String strSource=txtSource.getText()时与目标相同,没有错误,但只有catch,但目标文件夹为空。如果你们对我的问题感到困惑,我会尽力向你们解释

我的
文本框有问题。我正在尝试复制arraylist中的文件并将其传输到另一个文件夹

当我使用以下命令时:
String strSource=“D:\\New folder\\”
String strDestination=“D:\\New folder\\other 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();
                }
String strSource=新字符串(txtSource.getText());
String strDestination=新字符串(txtDestination.getText());
试一试{
ArrayList=readConfigFileList(ConstantVariables.SPECIFIC_FILE_list);
for(字符串strList:list){
复制文件(strSource+strList、strDestination+strList);
}
}捕获(IOE异常){
//TODO自动生成的捕捉块
e、 printStackTrace();
}

这是我的解决方案,我刚刚添加了
\


String strSource=txtSource.getText()+“\\;

请将您的问题包括在完整的堆栈跟踪中(很可能它已经试图告诉您问题出在哪里)。另外,请提供一个……因为您已经说明文件复制代码是有效的,“最小示例”在这种情况下可能意味着打印由
getText
”返回的意外
字符串
。@KevinJ.Chase我的问题已经由我自己回答了。我需要在这里发布我的答案吗?