java 如何读进文件内容时过滤逗号
2个回答
展开全部
package com.kk.tool;
import java.util.StringTokenizer;
/** java 如何读进文件内容时过滤逗号 */
public class Filter {
public static final String FT = ",,";
public static String fileInfo = "ad,,,dkfj,sad;fjiwefjsa,,f,fas,f,,a,,sdfs,dfas,df";
public static String dhFilter(String fileInfo) {
StringTokenizer stk = new StringTokenizer(fileInfo, FT);
StringBuffer sb = new StringBuffer();
while (stk.hasMoreTokens()) {
sb.append(stk.nextToken());
}
return sb.toString();
}
public static void main(String[] args) {
System.out.println(fileInfo);
System.out.println(dhFilter(fileInfo));
}
}
ad,,,dkfj,sad;fjiwefjsa,,f,fas,f,,a,,sdfs,dfas,df
addkfjsad;fjiwefjsaffasfasdfsdfasdf
import java.util.StringTokenizer;
/** java 如何读进文件内容时过滤逗号 */
public class Filter {
public static final String FT = ",,";
public static String fileInfo = "ad,,,dkfj,sad;fjiwefjsa,,f,fas,f,,a,,sdfs,dfas,df";
public static String dhFilter(String fileInfo) {
StringTokenizer stk = new StringTokenizer(fileInfo, FT);
StringBuffer sb = new StringBuffer();
while (stk.hasMoreTokens()) {
sb.append(stk.nextToken());
}
return sb.toString();
}
public static void main(String[] args) {
System.out.println(fileInfo);
System.out.println(dhFilter(fileInfo));
}
}
ad,,,dkfj,sad;fjiwefjsa,,f,fas,f,,a,,sdfs,dfas,df
addkfjsad;fjiwefjsaffasfasdfsdfasdf
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询