If you use the same path for reading, it works fine. Well, just create a subdir in the user dir ("user.dir" system property) with a leading dot (eg ".foo").
the problem is that when "file.txt" is read, it reads it from inside the jar and when i write it, its written on the desktop.
Another question (not related, but dont wanna start a new thread).
Suppose i have an array of bytes 60x1000. And depending on what the value is i wanna draw a sprite at certain position.
1 2 3 4 5 6 7 8 9
| for(int i=0;i<20;i++) for(int j=0;j<10;j++){ int x1=i*50,y1=j*50; if(arr[i][j]==0)g.drawImage(img0,x1,y1,null,this); else if(arr[i][j]==1)g.drawImage(img1,x1,y1,null,this); else if(arr[i][j]==2)g.drawImage(img2,x1,y1,null,this); ... else if(arr[i][j]==30)g.drawImage(img30,x1,y1,null,this); } |
I was wondering since the cell value corresponds to the image name, can i do something like this
1 2 3 4 5
| for(int i=0;i<20;i++) for(int j=0;j<10;j++){ int x1=i*50,y1=j*50; g.drawImage("img"+toString(arr[i][j]),x1,y1,null,this); } |
not sure if that'll work, but u get the idea