HTTPヘッダーとデータ転送速度を持たないHTMLファイルのサイズを探したい。以下は私のコードです。HTMLファイルのサイズとデータ転送速度を調べる方法
import java.net.*;
import java.io.*;
public class HttpCon
{
public static void main (String[] args) throws IOException
{
Socket s = null;
try
{
String host = "host1";
String file = "file1";
int port = 80;
s = new Socket(host, port);
OutputStream out = s.getOutputStream();
PrintWriter outw = new PrintWriter(out, false);
outw.print("GET " + file + " HTTP/1.1\r\n");
outw.print("Host: " + host + ":" + port + "\r\n");
outw.print("Accept: text/plain, text/html, text/*\r\n");
outw.print("\r\n");
outw.flush();
InputStream in = s.getInputStream();
InputStreamReader inr = new InputStreamReader(in);
BufferedReader br = new BufferedReader(inr);
String line;
while ((line = br.readLine()) != null)
{
System.out.println(line);
}
br.close();
}
}
}
しかし、これを行う方法はわかりません。私が見ることができるソースコードや、私が適用できるリソースはありますか?
ご協力いただきありがとうございます。
コードの貼り付けが大規模で、これを行う方法がわかりません。どのようにすればよいのか分かりませんか? – zmccord
@zmccord実際には2つの問題があります。まず、このコードでダウンロードしたHTTPヘッダーのないHTMLファイルのサイズを調べる必要があります。特定の機能やその他の推奨事項はありますか?第二に、サイズを計算した後、私はデータ転送速度を見つけなければならない。 – user1349536