package io;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException; public class First { public static void main(String[] args) throws IOException {
int a=0;int b=0;int c=0;int d=0;int e=0;int f=0;int g=0;int h=0;int i=0;int j=0;int k=0;int l=0;int m=0;int n=0;int o=0;int p=0;int q=0;
int r=0;int s=0;int t=0;int u=0;int v=0;int w=0;int x=0;int y=0;int z=0;
int A=0;int B=0;int C=0;int D=0;int E=0;int F=0;int G=0;int H=0;int I=0;int J=0;int K=0;int L=0;int M=0;int N=0;int O=0;int P=0;int Q=0;
int R=0;int S=0;int T=0;int U=0;int V=0;int W=0;int X=0;int Y=0;int Z=0;
// 新文件
File newFile = new File("d:\\File.txt");
char[] data=new char[1000];
// 读取文件内容
File file = new File("d:\\file.txt");
BufferedReader reader = new BufferedReader(new FileReader(file));
StringBuffer sb = new StringBuffer();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line);
System.out.println(line);
}
reader.close();
// 统计字母个数 for (int ii = 0; ii < sb.length(); ii++) {
char ch = sb.charAt(ii);
for(int qq=0;qq<1000;qq++) {
data[qq]=ch;
}
for(int qq=0;qq<1000;qq++) {
System.out.print(data[qq]);
}
if(ch=='A') {
A++;
}
if(ch=='B') {
B++;
}
if(ch=='C') {
C++;
}
if(ch=='D') {
D++;
}
if(ch=='E') {
E++;
}
if(ch=='F') {
F++;
}
if(ch=='G') {
G++;
}
if(ch=='H') {
H++;
}
if(ch=='I') {
I++;
}
if(ch=='J') {
J++;
}
if(ch=='K') {
K++;
}
if(ch=='L') {
L++;
}
if(ch=='M') {
M++;
}
if(ch=='N') {
N++;
}
if(ch=='O') {
O++;
}
if(ch=='P') {
P++;
}
if(ch=='Q') {
Q++;
}
if(ch=='R') {
R++;
}
if(ch=='S') {
S++;
}
if(ch=='T') {
T++;
}
if(ch=='U') {
U++;
}
if(ch=='V') {
V++;
}
if(ch=='W') {
W++;
}
if (ch=='X') {
X++;
} if (ch=='Y') {
Y++;
}
if (ch=='Z') {
Z++;
}
if (ch=='a') {
a++;
}
if (ch=='b') {
b++;
}
if (ch=='c') {
c++;
} if (ch=='d') {
d++;
}
if (ch=='e') {
e++;
}
if (ch=='f') {
f++;
}
if (ch=='g') {
g++;
}
if (ch=='h') {
h++;
}
if (ch=='i') {
i++;
}
if (ch=='j') {
j++;
}
if (ch=='k') {
k++;
}
if (ch=='l') {
l++;
}
if (ch=='m') {
m++;
}
if (ch=='n') {
n++;
}
if (ch=='o') {
o++;
}
if (ch=='p') {
p++;
}
if (ch=='q') {
q++;
}
if (ch=='r') {
r++;
}
if (ch=='s') {
s++;
}
if (ch=='t') {
t++;
}
if (ch=='u') {
u++;
}
if (ch=='v') {
v++;
}
if (ch=='w') {
w++;
}
if (ch=='x') {
x++;
}
if (ch=='y') {
y++;
}
if (ch=='z') {
z++;
}
}
System.out.println("a:"+a+"\t"+"b:"+b+"\t"+"c:"+c+"\t"+"d"+d);
System.out.println("e:"+e+"\t"+"f:"+f+"\t"+"g:"+g+"\t"+"h"+h);
System.out.println("i:"+i+"\t"+"j:"+j+"\t"+"k:"+k+"\t"+"l"+l);
System.out.println("m:"+m+"\t"+"n:"+n+"\t"+"o:"+o+"\t"+"p"+p);
System.out.println("q:"+q+"\t"+"r:"+r+"\t"+"s:"+s+"\t"+"t"+t);
System.out.println("u:"+u+"\t"+"v:"+v+"\t"+"w:"+w+"\t"+"x"+x);
System.out.println("y:"+y+"\t"+"z:"+z+"\t");
System.out.println("A:"+A+"\t"+"B:"+B+"\t"+"C:"+C+"\t"+"D"+D);
System.out.println("E:"+E+"\t"+"F:"+F+"\t"+"G:"+G+"\t"+"H"+H);
System.out.println("I:"+I+"\t"+"J:"+J+"\t"+"K:"+K+"\t"+"L"+L);
System.out.println("M:"+M+"\t"+"N:"+N+"\t"+"O:"+O+"\t"+"P"+P);
System.out.println("Q:"+Q+"\t"+"R:"+R+"\t"+"S:"+S+"\t"+"T"+T);
System.out.println("U:"+U+"\t"+"V:"+V+"\t"+"W:"+W+"\t"+"X"+X);
System.out.println("Y:"+Y+"\t"+"Z:"+Z);
}
}

Java查找统计文中字母,单词的更多相关文章

  1. JAVA实验--统计文章中单词的个数并排序

    分析: 1)要统计单词的个数,就自己的对文章中单词出现的判断的理解来说是:当出现一个非字母的字符的时候,对前面的一部分字符串归结为单词 2)对于最后要判断字母出现的个数这个问题,我认为应该是要用到ma ...

  2. java统计英文字母、空格、数字和其它字符的数目

    package tes; import java.util.Scanner; //java统计英文字母,空格,数字和其它字符的数目 public class ZiFuTongJi { public s ...

  3. java统计文本中单词出现的个数

    package com.java_Test; import java.io.File; import java.util.HashMap; import java.util.Iterator; imp ...

  4. LeetCode 5216. 统计元音字母序列的数目(Java)DP

    5216. 统计元音字母序列的数目 给你一个整数 n,请你帮忙统计一下我们可以按下述规则形成多少个长度为 n 的字符串: 字符串中的每个字符都应当是小写元音字母('a', 'e', 'i', 'o', ...

  5. PHP统计字符串里单词查询关键字

    <?function full_count_words($str) {     //返回完整数组,包含字符串里每个单词 $words = str_word_count($str,1);     ...

  6. java string,需要进行首字母大写改写

    java string,需要进行首字母大写改写,网上大家的思路基本一致,就是将首字母截取,转化成大写然后再串上后面的,类似如下代码 //首字母大写     public static String c ...

  7. c程序设计语言_习题1-13_统计输入中单词的长度,并且根据不同长度出现的次数绘制相应的直方图

    Write a program to print a histogram of the lengths of words in its input. It is easy to draw the hi ...

  8. C语言习题1.分别统计一下其中字母,数字,其他字符的个数。将统计的字母,数字,其他字符的个数以柱状图的形式打印

    从键盘上输入字符,(1)分别统计一下其中字母,数字,其他字符的个数, (2)将统计的字母,数字,其他字符的个数以柱状图的形式打印.例如 5 ***** *****     3 *****   **** ...

  9. Java中过滤出字母、数字和中文的正则表达式

    1.Java中过滤出字母.数字和中文的正则表达式 (1)过滤出字母的正则表达式 [^(A-Za-z)] (2)过滤出数字的正则表达式 [^(0-9)] (3)过滤出中文的正则表达式 [^(\\u4e0 ...

随机推荐

  1. Android Studio启动模拟器失败

    启动Android Studio的模拟器报“Emulator: Process finished with exit code -1073741819 (0xC0000005)”错误教程: 1.进入该 ...

  2. 单选多选(CocosCreator)

    推荐阅读:  我的CSDN  我的博客园  QQ群:704621321 1.前沿       首先来说说我们的需求吧:随机出现单选题或者多选题,完全回答正确才算正确(多选题中少选错选算错),核实答案的 ...

  3. leetcode9 Palindrome Number(按进阶要求)

    题目描述 Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same ...

  4. 日志RedisTemplate 存储

    import org.springframework.beans.factory.annotation.Autowired;import org.springframework.data.redis. ...

  5. [python]多元赋值

    1. 简介 将多个变量同时赋值的方法,称为多元赋值. 2. 示例一: x, y, z = 1, 2, 'a string' print x, y, z 运行结果: 1 2 a string

  6. Luogu-P1027 Car的旅行路线 已知三点确定矩形 + 最短路

    传送门:https://www.luogu.org/problemnew/show/P1027 题意: 图中有n个城市,每个城市有4个机场在矩形的四个顶点上.一个城市间的机场可以通过高铁通达,不同城市 ...

  7. POJ3233 Matrix Power Series 矩阵快速幂 矩阵中的矩阵

    Matrix Power Series Time Limit: 3000MS   Memory Limit: 131072K Total Submissions: 27277   Accepted:  ...

  8. codeforces 798 C. Mike and gcd problem(贪心+思维+数论)

    题目链接:http://codeforces.com/contest/798/problem/C 题意:给出一串数字,问如果这串数字的gcd大于1,如果不是那么有这样的操作,删除ai, ai + 1 ...

  9. PAT L3-017. 森森快递

    L3-017. 森森快递 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 俞勇(上海交通大学) 森森开了一家快递公司,叫森森快递.因为 ...

  10. Fedora7 安装完全过程

    操作系统课要用Fedora7 安装配置真是一把辛酸泪呀..... 首先是找镜像文件(这个就找了好久.....): https://archives.fedoraproject.org/pub/arch ...