JavaTCP 上傳文字檔案

2021-09-09 07:55:29 字數 758 閱讀 3301

基於聊天客戶端的基礎上的檔案(txt檔案)傳輸

客戶端**:

public class uploadclient 

//告訴服務端,客戶端寫完了

s.shutdownoutput();

//4,讀取服務端返回的上傳成功物件

bufferedreader bufin = new bufferedreader(new inputstreamreader(s.getinputstream()));

string str = bufin.readline();

system.out.println(str);

//關閉資源

bufr.close();

s.close();

}}

服務端**:

public static void main(string args) throws unknownhostexception, ioexception 

printwriter out = new printwriter(s.getoutputstream(),true);

out.println("上傳成功");

bufw.close();

s.close();//關閉客戶端

ss.close();//關閉服務端

}

要注意的是tcp傳輸中,一定要先執行服務端再執行客戶端。

文字檔案 Excel檔案上傳下傳

text convert xls to sap函式可以將本地的文字檔案 列與列之間預設使用tab鍵分開,但也可以指定 或真正的excel檔案上傳到服務內錶中,並且檔案轉換成內錶中的資料是自動完成,不需要手動,這與alsm excel to internal table函式是不一樣的 paramete...

讀取文字檔案

void ctestdlg onreadinfo cfile filewrite1 testwrite1.txt cfile modecreate cfile modewrite cfile filewrite2 testwrite2.txt cfile modecreate cfile modew...

寫文字檔案

textoper 文字檔案操作類 public class textoper 新建乙個檔案 public bool createfile string strpath,string strname else file.create strpath strname return true catch ...