我有这个问题,我不知道怎么解决。以下是问题所在:
1-我的数据库中有一个数据,我将其拆分为一个strings[],然后将这个strings[]拆分为另一个字符串even and odd lines。一切都很好,但是当我想把所有的行连接到一个字符串中时,我得到了一个单行的多行字符串整数。有人能帮我吗?
数据
abcdef//
123456//
ghijkl//
789012代码:
String text = "";
vec1 = data.split("//"); //split the data
int LE = 0;
for (int a = 0; a < vec1.length; a++) { //verify how many even and odds line the data have
if (a % 2 == 0) { //if 0, LE++
LE++;
}
}
resul1 = new String[LE];
int contA = 0, contB = 0;
for (int c = 0; c < resul1.length; c++) {
if (c % 2 != 0) {
text += " " + resul1[c].toLowerCase().replace("Á","a").replace("Ã","a").replace("ã","a").replace("â","a").replace("á","a").replace("é","e").replace("É","e")
.replace("ê","e").replace("í","i").replace("Í","i").replace("ó","o").replace("Ó","o").replace("õ","o").replace("Õ","o").replace("ô","o").replace("Ô", "o")
.replace("Ú","u").replace("ú","u").replace("ç","c").replace("_","").replace("<","").replace(">","");
contA++;
}
}而这串看起来就像
abcdef
ghijkl而不是
abcdefghijkl发布于 2014-04-25 15:09:17
您应该使用replaceAll()方法。
text.replaceAll("\\r\\n|\\r|\\n", ""); // the method removes all newline charactershttps://stackoverflow.com/questions/23091236
复制相似问题