課程
/后端開發(fā)
/Java
/Java Socket應(yīng)用---通信是這樣練成的
怎么傳輸文件啊 ?ConfigManager ?什么的 ?不行啊
2016-11-12
源自:Java Socket應(yīng)用---通信是這樣練成的 5-1
正在回答
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class BrAndBwOrPwDemo {
public static void main(String[] args) throws IOException{
//對(duì)文件進(jìn)行讀寫操作?
BufferedReader br = new BufferedReader(
new InputStreamReader(
new FileInputStream("e:\\javaio\\imooc.txt")));
/*BufferedWriter bw = new BufferedWriter(
new OutputStreamWriter(
new FileOutputStream("e:\\javaio\\imooc3.txt")));*/
PrintWriter pw = new PrintWriter("e:\\javaio\\imooc4.txt");
//PrintWriter pw1 = new PrintWriter(outputStream,boolean autoFlush);
String line ;
while((line = br.readLine())!=null){
System.out.println(line);//一次讀一行,并不能識(shí)別換行
/*bw.write(line);
//單獨(dú)寫出換行操作
bw.newLine();//換行操作
bw.flush();*/
pw.println(line);
pw.flush();
}
br.close();
//bw.close();
pw.close();
利用文件讀寫方式將其讀取后包裝到數(shù)據(jù)報(bào)或直接通過TCP進(jìn)行數(shù)據(jù)傳遞
舉報(bào)
分享的是 Java 中的網(wǎng)絡(luò)編程,使用Socket實(shí)現(xiàn)網(wǎng)絡(luò)聊天通信
1 回答文件傳輸問題
1 回答輸出data 的時(shí)候 控制臺(tái)怎么沒換行啊
1 回答文件傳輸基礎(chǔ)
1 回答為什么要用Arrays.toString()方法進(jìn)行輸出啊
1 回答有文件的傳輸方式的代碼么,都是字符串的
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2016-11-12
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
public class BrAndBwOrPwDemo {
public static void main(String[] args) throws IOException{
//對(duì)文件進(jìn)行讀寫操作?
BufferedReader br = new BufferedReader(
new InputStreamReader(
new FileInputStream("e:\\javaio\\imooc.txt")));
/*BufferedWriter bw = new BufferedWriter(
new OutputStreamWriter(
new FileOutputStream("e:\\javaio\\imooc3.txt")));*/
PrintWriter pw = new PrintWriter("e:\\javaio\\imooc4.txt");
//PrintWriter pw1 = new PrintWriter(outputStream,boolean autoFlush);
String line ;
while((line = br.readLine())!=null){
System.out.println(line);//一次讀一行,并不能識(shí)別換行
/*bw.write(line);
//單獨(dú)寫出換行操作
bw.newLine();//換行操作
bw.flush();*/
pw.println(line);
pw.flush();
}
br.close();
//bw.close();
pw.close();
}
}
利用文件讀寫方式將其讀取后包裝到數(shù)據(jù)報(bào)或直接通過TCP進(jìn)行數(shù)據(jù)傳遞