database - Java:Change String content -


in application user give name of database file he/she want create database file , application create database @ location user provided name. of filechooser user give name of database , when he/she click on save button 1 database file created @ place. code:

public class stringspilt1 {   public static void main(string[] argv)     throws classnotfoundexception, instantiationexception, illegalaccessexception, unsupportedlookandfeelexception {     uimanager.setlookandfeel(uimanager.getsystemlookandfeelclassname());     jfilechooser filechooser = new jfilechooser();     filechooser.showsavedialog(null);     system.out.println(filechooser.getselectedfile());     createdatabase((filechooser.getselectedfile()).tostring());    }  private static void createdatabase(string string) {     string databasename = string; //      string databasename = "d:\\msaccessproject/griss.mdb";         database database = createdatabase(databasename);     // rest of code } } 

now problem (filechooser.getselectedfile()).tostring() return path in way:

d:\msaccessproject\griss.mdb

and creating database need path in way: d:\\msaccessproject/griss.mdb"

how can solve problem.

either use double slashes "\\" or single forward slash "/". guess should solve problem. after getting path filechooser.getselectedfile()).tostring(); perform following operation:

path.replace("\","/"); 

Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -