Android Open Source - mazer Post






From Project

Back to project page mazer.

License

The source code is released under:

GNU General Public License

If you think the Android project mazer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.spatialia.santa.util;
/*from  w w  w  . ja  v  a  2 s  .  c o m*/
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Field;
import java.net.HttpURLConnection;
import java.net.URL;

public class Post {

  public static String doPost(String url, String urlParameters)
      throws Exception {
    HttpURLConnection connection = (HttpURLConnection) getURL(url)
        .openConnection();
    connection.setDoOutput(true);
    connection.setDoInput(true);
    connection.setInstanceFollowRedirects(false);
    connection.setRequestMethod("POST");
    connection.setRequestProperty("Content-Type",
        "application/x-www-form-urlencoded");
    connection.setRequestProperty("charset", "utf-8");
    connection.setRequestProperty("Content-Length",
        "" + Integer.toString(urlParameters.getBytes().length));
    connection.setUseCaches(false);

    DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
    wr.writeBytes(urlParameters);
    wr.flush();
    wr.close();

    BufferedReader rd = new BufferedReader(new InputStreamReader(
        connection.getInputStream()));

    String response = "";
    String line = null;
    while ((line = rd.readLine()) != null) {
      response += line;
    }
    rd.close();
    connection.disconnect();
    return response;
  }

  private static URL getURL(String url) throws Exception {
    URL u = new URL(url);
    if (url.endsWith("?")) {
      Field f = u.getClass().getDeclaredField("file");
      f.setAccessible(true);

      String file = (String) f.get(u);

      if (!file.endsWith("?")) {
        f.set(u, file + "?");
      }
    }
    return u;
  }
}




Java Source Code List

org.spatialia.santa.AlertDialog.java
org.spatialia.santa.GameEngine.java
org.spatialia.santa.GameInput.java
org.spatialia.santa.GameView.java
org.spatialia.santa.MainActivity.java
org.spatialia.santa.Sprite.java
org.spatialia.santa.Tile.java
org.spatialia.santa.logic.LevelManager.java
org.spatialia.santa.logic.Level.java
org.spatialia.santa.logic.Settings.java
org.spatialia.santa.util.JobRunner.java
org.spatialia.santa.util.Perf.java
org.spatialia.santa.util.Post.java