public synchronized void writeProgress(int current_file, int total_files) {
    try {

      DataOutputStream out =
          new DataOutputStream(new BufferedOutputStream(new FileOutputStream(resume_file, false)));
      out.writeInt(current_file);
      out.writeInt(total_files);
      out.flush();
      out.close();

    } catch (FileNotFoundException e) {
      e.printStackTrace();
      Log.e(TAG, "writeProgress resume.txt not found.");
    } catch (IOException ex) {
      Log.e(TAG, "Unable to create resume.txt.");
    }
  }
Ejemplo n.º 2
0
    protected Void doInBackground(Void... params) {
      String outString;
      HttpURLConnection c = null;
      DataOutputStream os = null;

      outString = scanData.getOwnBSSID();
      outString = outString + "\nL\tX\t" + lastLat + "\t" + lastLon + "\n";

      try {
        URL connectURL = new URL("http://www.openwlanmap.org/android/upload.php");
        c = (HttpURLConnection) connectURL.openConnection();
        if (c == null) {
          return null;
        }

        c.setDoOutput(true); // enable POST
        c.setRequestMethod("POST");
        c.addRequestProperty("Content-Type", "application/x-www-form-urlencoded, *.*");
        c.addRequestProperty("Content-Length", "" + outString.length());
        os = new DataOutputStream(c.getOutputStream());
        os.write(outString.getBytes());
        os.flush();
        c.getResponseCode();
        os.close();
        outString = null;
        os = null;
      } catch (IOException ioe) {
      } finally {
        try {
          if (os != null) os.close();
          if (c != null) c.disconnect();
        } catch (IOException ioe) {
          ioe.printStackTrace();
        }
      }
      return null;
    }