更新: POST リクエストは正常に処理されます。唯一の問題は、入力コード (以下を参照) を実行すると、入力コードがコメントアウトされている場合でも、入力コード自体ではなく、入力コードの出力がポストされることです。
入力コード (zigzby): http://pastebin.com/5mZHpX7gは、入力として使用しているこのプログラムの以前のバージョンです。
現在、pastebin.com の出力は「ha」です。
完全なコード: http://pastebin.com/qGiFUnyK
具体的には:
String zigzby = classEditor.getText(beginningLocation, endingLocation);
String encodedString = URLEncoder.encode(zigzby, "UTF-8");
encodedString = encodedString.replaceAll("%0A", "\r\n");
Scanner input = new Scanner(System.in);
System.out.println("Enter your pastebin code:");
String urlParameters = "api_option=paste&api_paste_code="+zigzby+"&api_dev_key=REVOKED&api_paste_expire_date=1M";
URL myURL = new URL("http://pastebin.com/api/api_post.php");
HttpURLConnection myURLConnection = (HttpURLConnection)myURL.openConnection();
myURLConnection.setDoOutput(true);
myURLConnection.setRequestMethod("POST");
myURLConnection.connect();
OutputStreamWriter writer = new OutputStreamWriter(myURLConnection.getOutputStream());
writer.write(urlParameters);
writer.flush();