アットウィキロゴ

game1203

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

public class game1203{

    public static void main(String[] args) {
int n;
int number;      
String data[]=new String[1000];

String urlString = "http://www11.atpages.jp/ce00582/a1.php";
        try {
            URL url = new URL(urlString);
            URLConnection uc = url.openConnection();
            
           uc.setDoOutput(true);
           OutputStream os = uc.getOutputStream();
            String postStr = "x=100&y=bar";
            PrintStream ps = new PrintStream(os);
            ps.print(postStr);
            ps.close();

            InputStream is = uc.getInputStream();
            BufferedReader reader = new BufferedReader(new InputStreamReader(is));
            String s;
            n=0;
            while ((s = reader.readLine()) != null) {
             n=n+1;
data[n]=s;            
}
number=n;
            reader.close();
for(n=1;n<number+1;n++){
System.out.println(data[n]);
}



        } catch (MalformedURLException e) {
            System.err.println("Invalid URL format: " + urlString);
            System.exit(-1);
        } catch (IOException e) {
            System.err.println("Can't connect to " + urlString);
            System.exit(-1);
        }
    }
}
最終更新:2011年02月10日 09:19