im trying to jar my client and make the cache download from a website to the users home so the client is more universal. its really starting to piss me off. it wont connect to the server and i get the this error when i debug it.
java.io.FileNotFoundException: nullIcache31\sprites.dat (The system cannot find the path specified) at java.io.RandomAccessFile.open(Native Method) at java.io.RandomAccessFile.<init>(Unknown Source) at java.io.RandomAccessFile.<init>(Unknown Source) at CustomSprites.loadCustomSprites(CustomSprites.java:11) at Gui.<init>(Gui.java:109) at Gui.main(Gui.java:38)
here is my code
public static void loadCustomSprites(client var_client) { try { RandomAccessFile cache = new RandomAccessFile(System.getProperty("home") + "Icache31/sprites.dat", "r"); RandomAccessFile cache_idx = new RandomAccessFile(System.getProperty("home") + "Icache31/sprites.idx", "r"); Cache ch = new Cache(cache, cache_idx, 0); Map<String, Image> images = new HashMap<String, Image>(); for(int i=0; i < ch.getNumFiles(); i++) { byte[] buffer = ch.getFile(i); if(buffer == null) { continue; } DataStream str = new DataStream(buffer.length, 0); System.arraycopy(buffer, 0, str.inBuffer, 0, buffer.length); String name = str.readString(); Image img = Toolkit.getDefaultToolkit().createImage(str.inBuffer, str.readOffset(), str.inBuffer.length - str.readOffset()); if(img != null) { images.put(name, img); } } MediaTracker mediaTracker = new MediaTracker(var_client); for(Image i : images.values()) { mediaTracker.addImage(i, 0); } try { mediaTracker.waitForAll(); } catch (InterruptedException e) { e.printStackTrace(); } for(String name : images.keySet()) { Image i = images.get(name); if(i == null) { continue; } int[] pixels = new int[i.getWidth(null) * i.getHeight(null)]; PixelGrabber pixelgrabber = new PixelGrabber(i, 0, 0, i.getWidth(null), i.getHeight(null), pixels, 0, i.getWidth(null)); pixelgrabber.grabPixels(); sprites.put(name, pixels); } //System.out.println("" + sprites.size() + " sprites successfully loaded!"); } catch(Exception e) { e.printStackTrace(); } }
when i did "user.home" it went to C:/OwnerIcache31/sprites.dat
wich is not right.. please help!