java中getchars方法_数组对象getChars()方法的使用

# re: 数组对象getChars()方法的使用  回复  更多评论

2009-03-24 18:45 by anven

你好,我刚刚在编写代码时候,出现了这样的情况,在buf.getChars(0,buf.indexOf(new String ("

for(int i=0,i<=100;i++)

tmp[i]=0;

这样过后,却出现不了预期的效果,却只循环了一次就停止了!实在不知道错在哪里!请教!

import java.io.*;

public class Filetest2

{

public static void main(String args[])

{

String str="";

BufferedReader in =null;

BufferedWriter out=null;

char tmp[]=new char[50];

int c=0;

try

{

in = new BufferedReader(new FileReader("2.1.txt"));

out= new BufferedWriter(new FileWriter("2.2.txt"));

while((str=in.readLine())!=null)

{

String str1= str.toLowerCase().replaceAll(new String(" "),new String (""));

StringBuffer buf= new StringBuffer(str1);

System.out.println(buf.indexOf(new String ("

if (buf.indexOf(new String ("

{

buf.getChars(0,buf.indexOf(new String ("

System.out.println(tmp);

String Strtmp=new String(tmp);

out.write(Strtmp);

out.newLine();

}

//buf.getChars(0,buf.indexOf(new String ("

//System.out.println(tmp);

//str1.getChars(str1.indexOf("*")+1,str1.indexOf("

//String Strtmp = new String(tmp);

//System.out.println(str1);

//out.write(str1);

//out.newLine();

}

}

catch(Exception e)

{

}

finally

{

try{

if(in!=null)

if(out!=null)

in.close();

out.close();

}

catch(Exception e)

{}

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值