我正在开发一个桌面应用程序,它使用XPath读取特定的XML元素并将其显示在文本字段中JFrame.
到目前为止,程序运行顺利,直到我决定String在File类中传递一个变量.
public void openNewFile(String filePath) {
//file path C:\\Documents and Settings\\tanzim.hasan\\my documents\\xcbl.XML
//is passed as a string from another class.
String aPath = filePath;
//Path is printed on screen before entering the try & catch.
System.out.println("File Path Before Try & Catch: "+filePath);
try {
//The following statement works if the file path is manually written.
// File xmlFile = new File ("C:\\Documents and Settings\\tanzim.hasan\\my documents\\xcbl.XML");
//The following statement prints the actual path
File …Run Code Online (Sandbox Code Playgroud)