int onechar; while ((onechar = in.read()) != -1) out.write(onechar);
int numchar; byte[] buffer = new byte[512]; while ((numchar = in.read(buffer)) != -1) out.write(buffer, 0, numchar);
  public static File getResourceAsFile(String name) throws IOException {    File myTempFile;    Object existingFile;        // Check if resource has already been extracted    if ((existingFile = temporaryFiles.get(name)) != null)      return (File)existingFile;        if(getResource(name) != null) {      // Create temp file      myTempFile = File.createTempFile("irate", name);      myTempFile.deleteOnExit();            // Open ressource      URL url = getResource(name);      URLConnection urlc = url.openConnection();      InputStream is = url.openStream();      BufferedReader in = new BufferedReader(new InputStreamReader(is));      BufferedWriter out = new BufferedWriter(new FileWriter(myTempFile));            // Copy resource into temp file      int onechar;      while ((onechar = in.read()) != -1)        out.write(onechar);            // Close streams      in.close();      out.close();            // Add file to filelist      temporaryFiles.put(name, myTempFile);            return myTempFile;    }    else      throw new IOException();  }