How to Read a File From Any Computer (Java) -


currently have code in program:

bufferedimage readpicture = null;             try {                 readpicture = imageio.read(new file("c:/users/john/documents/netbeansprojects/program5/build/classes/program5/pictures/testpicture.png"));             } catch (ioexception e) {             } 

if compile file jar , give else, program not work classpath specific computer. how can change how access files/images works on computers?

you can add folder in project named files or want.you can make sub-directories in , arrange files in that.they available when share others.in code below,"." represents working directory.so make sure directory structure providing,is correct.try this.

bufferedimage readpicture = null; try {          readpicture = imageio.read(new file("./files/pictures/testpicture.png"));       } catch (ioexception e) {      } 

see also


Comments