java - How do I get the path to a file from my current directory? -
i'm reading in file, problem can read in own directory, , in sub-directories, when use .getpath() gives me full path route e.g. c:\users\smandre\documents\file.txt. how can use path read in file program? i've tried `.getcanonicalpath()
int returnval = c.showopendialog(c); if(returnval == jfilechooser.approve_option) { setfilepath(c.getselectedfile().getpath()); try { br = new bufferedreader(new filereader(getfilepath())); } catch (filenotfoundexception e1) { // todo auto-generated catch block e1.printstacktrace(); } system.out.println("you chose open file: " + c.getselectedfile().getpath()); // system.out.println(classloader.getsystemresourceasstream(getfilepath())); return; } obviously above trying open file path starting system route, not current directory...
Comments
Post a Comment