# 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)
{}
}
}
}