求助charAt()用法出错问题!

来源:百度知道 编辑:UC知道 时间:2024/05/27 00:46:07
出错在int c = a[i].charAt(0); 这一句上,我不知道问题出在哪?请教回答,我是想要统计一个文本的数字和字母各多少,并且分别存在不用文本里。
public class Six {
public static void main(String args[]) throws IOException{

System.out.println("请输入您要查询的文件地址:");
BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
String path=bf.readLine();
System.out.println("您要查询的文件地址为:"+path);

File f=new File(path);
if(!f.exists()){
System.out.println("您要查询的文件不存在!");
}

Six one=new Six();
one.tongji(f);
}

private void tongji(File f) throws IOException {
//新建2个文件来存放统计后的字母和数字
File words=new File("c://words.txt");
File number=new File("c//number.txt");
FileWriter out1=new FileWriter(words); FileWriter out2=new FileWriter(number); try{
BufferedReader input=new BufferedReader(new FileReader(f));
String text=input.readLine(

//基础知识有待加强,至少&&和||不应该用错的,继续努力!

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;

public class Six {
public static void main(String args[]) throws IOException {

System.out.println("请输入您要查询的文件地址:");
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String path = bf.readLine();
bf.close();
System.out.println("您要查询的文件地址为:" + path);

File f = new File(path);
if (!f.exists()) {
System.out.println("您要查询的文件不存在!");
}

Six one = new Six();
one.tongji(f);
}

private void tongji(File f) throws IOException {
// 新建2个文件来存放统计后的字母和数字
File words = new File("c://words.txt");
File number = new File("c://number.txt");
if(!words.e