java--遍历字符个数

package test_1027;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Scanner;
import java.util.TreeMap;

public class ioStream {
public static void main(String[] args) throws IOException {
//FileInputStream
//method_1();
//method_2();
//method_3(fis, fos);
//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//extracted1();
//person p =new person(new Student1());
//p.code();
Scanner sc =new Scanner(System.in);
FileOutputStream fos =new FileOutputStream("yyy.txt",true);
//System.out.println();
while(true) {
String s= sc.nextLine();
char[] arr= s.toCharArray();
HashMap<Character, Integer> hm =new HashMap();
for (char c : arr) {
hm.put(c, !hm.containsKey(c) ? 1:hm.get(c)+1);
}
System.out.println(hm);
for (Character c : hm.keySet()) {
System.out.println(c+"---"+hm.get(c));
}
if(s.equals("q")){
break;
}

			fos.write(s.getBytes());
			fos.write("
".getBytes());
	}
	fos.close();
	
}

}

******************************人因为有理想、梦想而变得伟大,而真正伟大就是不断努力实现理想、梦想*****************************
原文地址:https://www.cnblogs.com/cloudLi/p/14179589.html