Search Results

Search found 1 results on 1 pages for 'user283188'.

Page 1/1 | 1 

  • java get file paths

    - by user283188
    hey everybody, I have a jsp page which contains the code which prints all files in a given directory and their file paths. The code is if (dir.isDirectory()) { File[] dirs = dir.listFiles(); for (File f : dirs) { if (f.isDirectory() && !f.isHidden()) { File files[] = f.listFiles(); for (File d : files) { if (d.isFile() && !d.isHidden()) { System.out.println(d.getName()+ d.getParent() + (d.length()/1024)); } } } if (f.isFile() && !f.isHidden()) { System.out.println(f.getName()+ f.getParent() + (f.length()/1024)); } } } The problem is that it prints the complete file path, which when accessed from tomcat is invalid. For example, the code spits out the following path: /usr/local/tomcat/sites/web_tech/images/scores/blah.jpg and I want it to only print the path up to /images ie /images/scores/blah.jpg I know I could just mess around with an actual string, ie splitting it or string matching, but is there an easier way to do it? Thanks

    Read the article

1