本文介紹了如何使用“標簽空間"在寫入文本文件時的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
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;
}
我在每列之間需要一個制表符空間"(寫入文本文件時).喜歡
i need "one tab space" in between each column(while writing to text file). like
manu 25 data1
manc 35 data3
在我的代碼中,我使用 bw.write(" ")
在每列之間創建空間.如何在那個地方使用一個標簽空間"而不是給空間".
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".
推薦答案
您可以使用
在文件中創建選項卡.
You can use
to create a tab in a file.
這篇關于如何使用“標簽空間"在寫入文本文件時的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!