删除空格 [英] Removing blank spaces

查看:81
本文介绍了删除空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

以下是java程序的一部分。

我正在读取db2中存储过程返回的结果集并将其写入文件。

我已经使用DataOutputStream dos将读取对象写入文件。


int totRows = 0;

System.out.println("结果集+(count-1)+写入文件...");

while(rs.next()){

totRows ++;

for(int i = 1; i< = col; i ++){

Object o = rs.getObject(i);

dos .writeChars(String.valueOf(o));

dos.writeUTF(" \t");

}

dos。 writeUTF(\\\\ nn);

}

System.out.println(totRows +" rows written ...");



输出为:文件内容r类似

TABLENAMETABLECOUNT

CUSTOMERINFOTABLE 6666

。 ...... 。

......

n等等


我希望它看起来像

TABLENAME TABLECOUNT

CUSTOMERINFOTABLE 6666

.............


这次至少得到一些帮助!

Hello,
Following is a part of java program.
I am reading Result Set returned by Stored Procedure in db2 and writing that into a file.
I have used DataOutputStream dos to write read object into file.

int totRows = 0;
System.out.println("Result Set"+(count-1)+" Writing into file...");
while (rs.next()) {
totRows++;
for (int i = 1; i <= col; i++) {
Object o = rs.getObject( i);
dos.writeChars(String.valueOf(o));
dos.writeUTF("\t");
}
dos.writeUTF("\r\n");
}
System.out.println(totRows+" rows written...");


Output is : File contents r like
T A B L E N A M E T A B L E C O U N T
C U S T O M E R I N F O T A B L E 6666
........
......
n so on


I want it to look like
TABLENAME TABLECOUNT
CUSTOMERINFOTABLE 6666
.............

Expect to get some help atleast this time!

推荐答案


你好,

以下是java程序的一部分。

我正在读取db2中存储过程返回的结果集并将其写入文件。

我已经使用DataOutputStream dos将read对象写入文件。


int totRows = 0;

System.out.println(" Result Set" +(count-1)+"写入文件...");

while(rs.next()){

totRows ++;

for(int i = 1; i< = col; i ++){

Object o = rs.getObject(i);

dos.writeChars(String.valueOf(o));

dos.writeUTF(" \t");

}

dos.writeUTF(" \\\\ ;

}

System.out.println(totRows +" rows written ...);



输出为:文件内容r类似

TABLENAMETABLECOUNT

CUSTOMERINFOTABLE 6666

........

......

n等等


我希望它看起来像

TABLENAME TABLECOUNT

CUSTOMERINFOTABLE 6666

.............


期待得到一些帮助至少这次!
Hello,
Following is a part of java program.
I am reading Result Set returned by Stored Procedure in db2 and writing that into a file.
I have used DataOutputStream dos to write read object into file.

int totRows = 0;
System.out.println("Result Set"+(count-1)+" Writing into file...");
while (rs.next()) {
totRows++;
for (int i = 1; i <= col; i++) {
Object o = rs.getObject( i);
dos.writeChars(String.valueOf(o));
dos.writeUTF("\t");
}
dos.writeUTF("\r\n");
}
System.out.println(totRows+" rows written...");


Output is : File contents r like
T A B L E N A M E T A B L E C O U N T
C U S T O M E R I N F O T A B L E 6666
........
......
n so on


I want it to look like
TABLENAME TABLECOUNT
CUSTOMERINFOTABLE 6666
.............

Expect to get some help atleast this time!



我不认为问题是由writeChars方法引起的,而是对象的String.valueOf是放入空格的那个。 (数字似乎没有发生?)。您可能需要先拆分输出:

I do not think the problem is caused by the writeChars method but rather the String.valueOf for your objects is the one that is putting in the spaces. (It does not seem to be happening for numbers?). You may need to split the output first:

展开 | 选择 | Wrap | 行号




forx解决方案!

它适用于字符串......但不适用于数字......

你能告诉我吗?wat可以完成4 dat吗?
Hi,
Thanx for the solution!
Its working properly for strings... but not for numbers...
can u tel me y so?wat can be done 4 dat?





解决方案!

它适用于字符串...但不适用于数字......

你可以打电话给我吗?wat可以做4个数据?
Hi,
Thanx for the solution!
Its working properly for strings... but not for numbers...
can u tel me y so?wat can be done 4 dat?



这些数字发生了什么变化?

What is happening for the numbers?


这篇关于删除空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆