How to upload data using POST-query?
<p>I have following problem: I'm developing the application which need to authorize on server and upload data from my mobile into it. The server side is ready and works correctly. So, for authorizing I use the following code:</p>

<pre><code>URL url = new URL(VALIDATING_URL);
                URLConnection connection=url.openConnection();
                connection.setDoOutput(true);
                PrintWriter out=new PrintWriter(connection.getOutputStream());
                out.print(POST_QUERY_EMAIL+email);
                out.print("&amp;");
                out.print(POST_QUERY_PASS+password);
                out.print("&amp;");
                out.print(POST_QUERY_CHANNEL+channel);
                out.close();
                Scanner in=new Scanner(connection.getInputStream());
                StringBuilder result=new StringBuilder();
                while (in.hasNextLine()) {
                    result.append(in.nextLine());
                    result.append("\n");
                }
                in.close();
</code></pre>

<p>It works correctly, and the application will get needed result if I enter correctly data. So, now I need to upload data into server using POST-query, but I don't know how I can do it. Using HTML forms, video is usually uploaded using 'userfile' variable and will be got from $_FILES array in PHP scipts. How can I upload do it from Java? Can I just print data into PrintStream from InputStream?</p>

<p>Thank you, I hope you can help me</p>
