基於上次的io流遍歷資料夾公升級了乙個gbk轉utf-8的方法:
把路徑換成你要轉換的檔案或者資料夾,該檔案或資料夾的所有gbk編碼的檔案就會變成utf-8編碼如果想u8->gbk 只需把**中的兩個編碼名稱調換位置即可
public
static
void
main
(string[
] args)
// 遍歷檔案方法
public
static
void
filelist
(file file)
system.out.
println
(f.getpath()
);// 遞迴呼叫子資料夾下的檔案
filelist
(f);}}
}//轉碼方法
public
static
void
codeconvert
(file file)
bufferedwriter bw =
newbufferedwriter
(new
outputstreamwriter
(new
fileoutputstream
(file)
, charset.
forname
("utf-8"))
);bw.
write
(sb.
tostring()
);bw.
flush()
; bw.
close()
;}catch
(exception e)
}
上傳檔案亂碼,GBK轉UTF 8
最近遇到這樣乙個問題,我上傳檔案沒有轉換字符集windows預設gbk,結果當我需要讀檔案顯示時用utf 8轉當然會出現亂碼,為了解決這個問題,我就將上傳時檔案一同也轉成utf 8了這樣就不會亂碼了,上傳時轉換字符集方法如下 string root filepath 上傳路徑 file rootfi...
TortoiseSVN忽略檔案或資料夾
tortosiesvn properties來設定svn ignore屬性 svn ignore global ignores區別 1 svn ignore 只對當前目錄有效 global ignores 是全域性有效,就是所有目前都有效 2 svn ignore 必須每個工作目錄都要設定,個性化配...
獲取系統資料夾或檔案
獲取檔案目錄 openfilename ofn 公共對話方塊結構。tchar szfile max path 儲存獲取檔名稱的緩衝區。初始化選擇檔案對話方塊。zeromemory ofn,sizeof openfilename ofn.lstructsize sizeof openfilename ...