如何使文件路径与嵌入式数据库兼容? (Apache Derby 嵌入式)

How to make a file path compatible with an embedded database? (Apache Derby Embedded)

最近我一直在尝试使用 JFileChooser 来 select 创建数据库;但是,我 运行 遇到的问题是我从 JFileChooser 获得的文件路径有反斜杠而不是正斜杠,我认为这是不允许我创建数据库的原因。这是我的代码,并尝试解决问题。

        try {
            // Try to connect to the database 
            DriverManager.registerDriver(new org.apache.derby.jdbc.EmbeddedDriver());
            databaseconnection = DriverManager.getConnection("jdbc:derby:"+formattedfolderpath+";");
            databaseconnection.setAutoCommit(false);
            currentdb = true;
        } catch (SQLException EX) {
           try {
                // Create the DB if it doesn't exist yet 
                DriverManager.registerDriver(new org.apache.derby.jdbc.EmbeddedDriver());
                databaseconnection = DriverManager.getConnection("jdbc:derby:"+formattedfolderpath+";create=true"); 
                databaseconnection.setAutoCommit(false);
                currentdb = true;
            } catch (SQLException EX2) {
                //infoBox("OH MY LAWD", "Error");
            }



    JButton open = new JButton();
    JFileChooser fc = new JFileChooser();
    fc.setCurrentDirectory(new java.io.File("C:/Users/1jenningst/Desktop"));
    fc.setDialogTitle("PDF Manager");
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    
    if (fc.showOpenDialog(open) == JFileChooser.APPROVE_OPTION){
        //
    }
    
    String folderpath = fc.getSelectedFile().getAbsolutePath();
    
    try{
        formattedfolderpath = new BufferedReader(new FileReader(folderpath));
    } catch (Exception e){
        //
    }
       
    selecting();
}

有人知道我如何使用变量来使用 JFileChooser 完成文件路径吗?
谢谢,
迈克尔

好的,
我只需要在文件路径中添加两个反斜杠,而不是一个:

C\users\missouri\desktop3

变成

C\users\missouri\desktop\123

希望这对您有所帮助,
特雷弗