how to use quot;tab spacequot; while writing in text file(如何使用“标签空间在写入文本文件时)
问题描述
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.
这篇关于如何使用“标签空间"在写入文本文件时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用“标签空间"在写入文本文件时


基础教程推荐
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 降序排序:Java Map 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01