91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 12.24MB
    文件類(lèi)型: .zip
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2023-06-19
  • 語(yǔ)言: 其他
  • 標(biāo)簽:

資源簡(jiǎn)介

東北大學(xué)實(shí)驗(yàn),網(wǎng)絡(luò)實(shí)踐。實(shí)驗(yàn)二代碼,http實(shí)現(xiàn) 東北大學(xué)實(shí)驗(yàn),網(wǎng)絡(luò)實(shí)踐。實(shí)驗(yàn)二代碼,http實(shí)現(xiàn)

資源截圖

代碼片段和文件信息



import?java.io.BufferedReader;
import?java.io.File;
import?java.io.FileOutputStream;
import?java.io.IOException;
import?java.io.OutputStream;
import?java.io.InputStream;
import?java.io.InputStreamReader;
import?java.io.PrintStream;
import?java.net.Socket;
import?java.net.SocketException;
import?java.net.UnknownHostException;
import?java.util.Scanner;

public?class?Client?{

public?static?void?main(String[]?args)?{
//?TODO?Auto-generated?method?stub

try?{
//鏈接服務(wù)器
//發(fā)送請(qǐng)求頭

while(true){
Socket?s=new?Socket(“l(fā)ocalhost“8888);
PrintStream?writer?=?new?PrintStream(s.getOutputStream());
System.out.println(“請(qǐng)輸入下載文件“);
String?filename?=?new?Scanner(System.in).nextLine();
writer.println(“GET?/“+filename+“?HTTP/1.1“);
writer.println(“Host:localhost“);
writer.println(“connection:keep-alive“);
writer.println();
writer.flush();

//發(fā)送請(qǐng)求體
InputStream?in=s.getInputStream();
BufferedReader?reader?=?new?BufferedReader(new?InputStreamReader(in));
String?firstLineOfResponse?=?reader.readLine();//Content-Type:text/html
String?secondLineOfResponse?=?reader.readLine();//Content-Length
String?threeLineOfResponse?=?reader.readLine();//blank?line
String?fourLineOfResponse?=?reader.readLine();//HTTP/1.1?200?OK

//接收響應(yīng)狀態(tài)
if((firstLineOfResponse.substring(9?12)).equals(“404“)){
????//響應(yīng)失敗
????String?result?=?new?String();
????String?line;
????while((line?=?reader.readLine())?!=?null){
???? result?=?result+“\n“+line;?
????}
????System.out.println(result);
????reader.close();
????writer.close();
}
else{
System.out.println(“請(qǐng)輸入保存路徑“);
String?savelocation?=?new?Scanner(System.in).nextLine();
File?fl?=?new?File(savelocation);
if(!fl.exists()){
fl.createNewFile();
}
if(fl.exists()){
byte[]?b=new?byte[100000];
OutputStream?out=new?FileOutputStream(savelocation);
int?len?=in.read(b);
while(len!=-1)
{
out.write(b?0?len);
len?=?in.read(b);
}
in.close();
out.close();
writer.close();
}
????}
s.close();
}
}
catch(UnknownHostException?e){
e.printStackTrace();
}catch(IOException?e){
e.printStackTrace();
}

}
}

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2018-01-19?11:20??實(shí)驗(yàn)二\
?????目錄???????????0??2018-01-19?11:20??實(shí)驗(yàn)二\實(shí)驗(yàn)二代碼\
?????文件????????2413??2017-03-07?17:08??實(shí)驗(yàn)二\實(shí)驗(yàn)二代碼\Client.java
?????文件?????????590??2017-03-06?22:15??實(shí)驗(yàn)二\實(shí)驗(yàn)二代碼\Server.java
?????文件????????3894??2017-03-07?17:12??實(shí)驗(yàn)二\實(shí)驗(yàn)二代碼\ServerThread.java
?????文件????????2866??2017-03-07?12:30??實(shí)驗(yàn)二\實(shí)驗(yàn)二代碼\ZipCompressor.java
?????文件????12956667??2017-03-07?21:31??實(shí)驗(yàn)二\董卓然實(shí)驗(yàn)二http錄屏.mp4

評(píng)論

共有 條評(píng)論

相關(guān)資源