Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Java SE 综合讨论区  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:【求助】新手请教关于编写一个wordcounter小程序的问题 [Re:liusmallsea]
caoyi





发贴: 32
积分: 0
于 2005-03-03 14:35 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
import java.io.*;
public class testaddsub
{
  public static void main(String[] args)
  {
    try
    {
      int count = 0;
  BufferedReader in = new BufferedReader(new FileReader("test.txt"));
  String str;
  while ((str = in.readLine()) != null)
  {
  for(int i=0;i <str.length();i++)
  {
    if(str.substring(i,str.length()).indexOf("a")>=0)
    {
      count++;
    }
  }
  }
  System.out.println(count);
  in.close();
  }
  catch (IOException e)
  {}
  }
}
不知道你要用数组干什么。
可以经常去http://www.javaalmanac.com/找找看类的用法和例子




话题树型展开
人气 标题 作者 字数 发贴时间
5085 【求助】新手请教关于编写一个wordcounter小程序的问题 liusmallsea 207 2005-02-28 18:19
4161 Re:【求助】新手请教关于编写一个wordcounter小程序的问题 凋谢的玫瑰 3783 2005-02-28 21:53
4006 Re:【求助】新手请教关于编写一个wordcounter小程序的问题 liusmallsea 29 2005-03-01 17:57
4829 Re:【求助】新手请教关于编写一个wordcounter小程序的问题 caoyi 668 2005-03-03 14:35

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923