導航:首頁 > 編程語言 > java王八

java王八

發布時間:2024-03-10 14:36:01

1. java 如何修改文件的某一行內容

importjava.io.BufferedReader;
importjava.io.File;
importjava.io.FileNotFoundException;
importjava.io.FileReader;
importjava.io.FileWriter;
importjava.io.IOException;
importjava.io.PrintWriter;
publicclassDay02_B{
staticStringpath="K:/Test/Name.txt";//路徑
publicstaticvoidmain(String[]args){
FilefileText=newFile(path);//文件
if(fileText.canExecute())//如果文件存在就繼續
setText(fileText,"剛","xx");//「剛」指定改為:「XX」
}
privatestaticvoidsetText(FilefileText,Stringtarget,Stringsrc){//修改
BufferedReaderbr=null;
PrintWriterpw=null;
StringBufferbuff=newStringBuffer();//臨時容器!
Stringline=System.getProperty("line.separator");//平台換行!
try{
br=newBufferedReader(newFileReader(fileText));
for(Stringstr=br.readLine();str!=null;str=br.readLine()){
if(str.contains(target))
str=str.replaceAll(target,src);
buff.append(str+line);
}
pw=newPrintWriter(newFileWriter(fileText),true);
pw.println(buff);
}catch(FileNotFoundExceptione){
e.printStackTrace();
}catch(IOExceptione){
e.printStackTrace();
}finally{
if(br!=null)
try{
br.close();
}catch(IOExceptione){
e.printStackTrace();
}
if(pw!=null)
pw.close();
}
}
}

2. java的get提交中文數據,得到亂碼,可為什麼亂碼大多是問號

舉個例子,現在我們都會漢語,有一天一個日本鬼子(客戶端請求的數據,擁有和你不同的編碼)來了和你(服務端是另一種編碼格式)對話。你會想著他會說什麼王八蛋之類,但是他卻說的八嘎呀路,這時候你就蒙了!用你的語言根本不理解也不知道他說的是什麼,所以你的腦海里出現了很多問號代表你解釋不了

閱讀全文

與java王八相關的資料

熱點內容
資料庫查詢系統源碼 瀏覽:617
php5314 瀏覽:358
完美國際安裝到哪個文件夾 瀏覽:669
什麼app可以掃一掃做題 瀏覽:540
程序員編碼論壇 瀏覽:924
淘點是什麼app 瀏覽:660
中國高等植物pdf 瀏覽:454
51單片機時間 瀏覽:182
後台如何獲取伺服器ip 瀏覽:267
單片機流水燈程序c語言 瀏覽:235
程序員第二職業掙錢 瀏覽:240
運行里怎麼輸入伺服器路徑 瀏覽:843
pythonstepwise 瀏覽:510
劉一男詞彙速記指南pdf 瀏覽:66
php認證級別 瀏覽:370
方舟編譯啥時候推送 瀏覽:1012
php手機驗證碼生成 瀏覽:677
哲學思維pdf 瀏覽:17
凌達壓縮機有限公司招聘 瀏覽:535
weblogic命令部署 瀏覽:39