第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

想咨詢一下關(guān)于FileOutputStream的問題,麻煩大佬幫忙看看~

想咨詢一下關(guān)于FileOutputStream的問題,麻煩大佬幫忙看看~

函數(shù)式編程 2022-01-06 20:07:20
代碼如下:Properties props = new Properties();InputStream is = getClass().getResourceAsStream("test.properties");try{props.load(is);is.close();System.out.println(props.getProperty("test"));props.setProperty("test", "reset");FileOutputStream fos = new FileOutputStream("test2",true);props.store(fos, null);fos.write("httpL//juncsu.blogcn.com".getBytes());fos.close();}catch(Exception ex){ex.printStackTrace();}結(jié)果是屬性文件的內(nèi)容可以讀出來,但是無法寫進(jìn)去,測試中FileOutputStream直接寫入也沒有反應(yīng)。不知道什么情況會(huì)導(dǎo)致這樣的問題?或者有其他寫Properties的方法?
查看完整描述

2 回答

?
慕桂英3389331

TA貢獻(xiàn)2036條經(jīng)驗(yàn) 獲得超8個(gè)贊

/**
* 讀出1.txt中的內(nèi)容,寫入2.txt中
*
*/

import java.io.*;

public class readwritefile{
public static void main(string[] args){
try{

file read = new file("c:\\1.txt");
file write = new file("c:\\2.txt");

bufferedreader br = new bufferedreader(
new filereader(read));
bufferedwriter bw = new bufferedwriter(
new filewriter(write));
string temp = null;
temp = br.readline();
while(temp != null){
//寫文件
bw.write(temp + "\r\n"); //只適用windows系統(tǒng)
//繼續(xù)讀文件
temp = br.readline();
}

bw.close();
br.close();

}catch(filenotfoundexception e){ //文件未找到
system.out.println (e);
}catch(ioexception e){
system.out.println (e);
}
}
}

 


查看完整回答
反對(duì) 回復(fù) 2022-01-10
?
慕后森

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超5個(gè)贊

FileOutputStream fos = new FileOutputStream("test2",true);
test2文件沒有擴(kuò)展名

查看完整回答
反對(duì) 回復(fù) 2022-01-10
  • 2 回答
  • 0 關(guān)注
  • 148 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)