Java 图像位置双斜杠

Java 图像位置双斜杠,java,image,imageicon,Java,Image,Imageicon,我使用文件选择器获取图像的位置。然后我把它保存在数据库里。它保存的位置类型为c:\doDocuments\3.jpg。然后我在JLabel中使用imageicon通过该位置显示图像 String s; JFileChooser jfc = new JFileChooser(); jfc.showDialog(jfc, "Choose an image file"); s = jfc.getSelect

我使用文件选择器获取图像的位置。然后我把它保存在数据库里。它保存的位置类型为c:\doDocuments\3.jpg。然后我在JLabel中使用imageicon通过该位置显示图像

            String s;
            JFileChooser jfc = new JFileChooser();
            jfc.showDialog(jfc, "Choose an image file");
            s = jfc.getSelectedFile().getAbsolutePath();
            tx_image.setText(s);

因此,问题在于imageicon提供的图像位置出错,因为imageicon需要的图像位置类型为c:\documents\3.jpg so。因此,如何使用文件选择器保存双斜杠位置而不是单斜杠。

1)请在句子开头添加大写字母。也可以用大写字母表示I,缩写和首字母缩略词如JEE或WAR。这使得人们更容易理解和帮助。2) 为了尽快获得更好的帮助,请发布一条。在将路径存储到数据库之前,为什么不将单斜杠替换为双斜杠?@reporter我知道这是可以做到的,但我想消除这个问题,每次我必须输入位置时,我都必须以双斜杠删除单斜杠。。。。
 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                Connection con =DriverManager.getConnection("jdbc:odbc:project","sa","123456");
                String s=tx_name.getText();
                Statement stmt= con.createStatement();
                ResultSet rs=stmt.executeQuery("SELECT name,address,email,startdate,enddate,reason,homeph,cellph,hourlyrate,image FROM driver");
                while(rs.next())
                {
                    if(s.equals(rs.getString(1)))
                    {
                        tx_address.setText(rs.getString(2));
                        tx_email.setText(rs.getString(3));
                        tx_startdate.setText(rs.getString(4));
                        tx_enddate.setText(rs.getString(5));
                        txf_reason.setText(rs.getString(6));
                        tx_homeph.setText(Integer.toString(rs.getInt(7)));
                        tx_cellph.setText(Integer.toString(rs.getInt(8)));
                        tx_hourlyrate.setText(Integer.toString(rs.getInt(9)));
                        s=rs.getString(10);
                        ic=new ImageIcon(s);
                        lb_image.setIcon(ic);
                        lb_image.setBounds(350,100,200,200);
                        break;