Java里面有没有类似.net里webrequest的类
展开全部
您好,我来为您解答:
java.net 对应 System.Net,典型的 URL 和 URLConnection。
URLConnection connect = url.openConnection();
// Specify connection settings
connect.setDoInput(true);
connect.setDoOutput(true);
// Get an output stream for writing
OutputStream output = connect.getOutputStream();
// Create a print stream, for easy writing
// PrintWriter writer = new PrintWriter ( new OutputStreamWriter ( output ) );
// writer.print ( query );
// writer.close();
PrintStream pout = new PrintStream(output);
pout.print(query);
pout.close();
// Open a connection
InputStream input = connect.getInputStream();
// Buffer the stream, for better performance
BufferedInputStream bufIn = new BufferedInputStream(input);
如果我的回答没能帮助您,请继续追问。
java.net 对应 System.Net,典型的 URL 和 URLConnection。
URLConnection connect = url.openConnection();
// Specify connection settings
connect.setDoInput(true);
connect.setDoOutput(true);
// Get an output stream for writing
OutputStream output = connect.getOutputStream();
// Create a print stream, for easy writing
// PrintWriter writer = new PrintWriter ( new OutputStreamWriter ( output ) );
// writer.print ( query );
// writer.close();
PrintStream pout = new PrintStream(output);
pout.print(query);
pout.close();
// Open a connection
InputStream input = connect.getInputStream();
// Buffer the stream, for better performance
BufferedInputStream bufIn = new BufferedInputStream(input);
如果我的回答没能帮助您,请继续追问。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询