java - Get file to be read from another package -


i need catch file package called files try use getresourceasstream or

file file = getclass().getresourceasstream("files/big.txt"));  

however, not working. saying convert url. if in case use url, downcasting, not working.

what can solve issue?

add 1 more slash "/" - if accessing package
commented information, read file use openstream() of url

 url url = getclass().getresource("/files/big.txt");      try {             bufferedreader in = new bufferedreader(new inputstreamreader(url.openstream()));             string namelist;             while ((namelist = in.readline()) != null) {                 system.out.println(namelist);             }         } catch (exception e) {             e.printstacktrace();         } 

Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -