Note that there are some explanatory texts on larger screens.

plurals
  1. POReferencing Files(Java) in an updater
    primarykey
    data
    text
    <p>I am writing an updater. I have this code:</p> <pre><code>package main; import java.io.*; import java.net.*; import java.util.*; import java.util.regex.Pattern; import java.lang.*; import static java.lang.System.out; public class UpdaterCore { public static void main(String args[]) throws IOException { java.io.BufferedInputStream inv = new java.io.BufferedInputStream(new java.net.URL("http://unicombox.tk/update/nv").openStream()); java.io.FileOutputStream fosv = new java.io.FileOutputStream("nv"); java.io.BufferedOutputStream boutv = new BufferedOutputStream(fosv,1024); byte data[] = new byte[1024]; while(inv.read(data,0,1024)&gt;=0) { boutv.write(data); } boutv.close(); inv.close(); //end version download Scanner VersionReader= new Scanner(new File ("v")).useDelimiter(","); int currentVersion= VersionReader.nextInt(); VersionReader.close(); Scanner NewVersionReader= new Scanner(new File ("nv")).useDelimiter(","); int newVersion= NewVersionReader.nextInt(); NewVersionReader.close(); if (newVersion&gt;currentVersion){ java.io.BufferedInputStream in = new java.io.BufferedInputStream(new java.net.URL("http://unicombox.tk/update/update.zip").openStream()); java.io.FileOutputStream fos = new java.io.FileOutputStream("update.zip"); java.io.BufferedOutputStream bout = new BufferedOutputStream(fos,1024); byte data1[] = new byte[1024]; while(in.read(data1,0,1024)&gt;=0) { bout.write(data1); } bout.close(); in.close(); out.println("Update successfully downloaded!"); } else{ out.println("You have the latest version!"); } } } </code></pre> <p>It gets the new version from a server, and then compares it to its current version. If the new version is greater than the current version, it downloads the update.</p> <p>I am having one big problem. My program can never find the files "v" and "nv"! "v" and "nv" are in the same folder as the compiled jar, yet I get a FileNotFound. What am I doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload