本文介紹了如何使用“標(biāo)簽空間"在寫入文本文件時(shí)的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
SimpleDateFormat formatter = new SimpleDateFormat("ddMMyyyy_HHmmSS");
String strCurrDate = formatter.format(new java.util.Date());
String strfileNm = "Cust_Advice_" + strCurrDate + ".txt";
String strFileGenLoc = strFileLocation + "/" + strfileNm;
String strQuery="select name, age, data from basetable";
try {
stmt = conn.createStatement();
System.out.println("Query is -> " + strQuery);
rs = stmt.executeQuery(strQuery);
File f = new File(strFileGenLoc);
OutputStream os = (OutputStream)new FileOutputStream(f);
String encoding = "UTF8";
OutputStreamWriter osw = new OutputStreamWriter(os, encoding);
BufferedWriter bw = new BufferedWriter(osw);
while (rs.next() ) {
bw.write(rs.getString(1)==null? "":rs.getString(1));
bw.write(" ");
bw.write(rs.getString(2)==null? "":rs.getString(2));
bw.write(" ");
}
bw.flush();
bw.close();
} catch (Exception e) {
System.out.println(
"Exception occured while getting resultset by the query");
e.printStackTrace();
} finally {
try {
if (conn != null) {
System.out.println("Closing the connection" + conn);
conn.close();
}
} catch (SQLException e) {
System.out.println(
"Exception occured while closing the connection");
e.printStackTrace();
}
}
return objArrayListValue;
}
我在每列之間需要一個(gè)制表符空間"(寫入文本文件時(shí)).喜歡
i need "one tab space" in between each column(while writing to text file). like
manu 25 data1
manc 35 data3
在我的代碼中,我使用 bw.write(" ")
在每列之間創(chuàng)建空間.如何在那個(gè)地方使用一個(gè)標(biāo)簽空間"而不是給空間".
in my code i use bw.write(" ")
for creating space between each column. how to use "one tab space" in that place instead of giving "space".
推薦答案
您可以使用
在文件中創(chuàng)建選項(xiàng)卡.
You can use
to create a tab in a file.
這篇關(guān)于如何使用“標(biāo)簽空間"在寫入文本文件時(shí)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!