怎么解决输入问题,信息自己输入怎么编啊
import *;class WriteFile{
public boolean writeFile(String str,String path,int i){
boolean check=true;
if(i==0){
check=false;
}
File fie=new File(path);
try{
FileWriter outFile=new FileWriter(fie,check);
BufferedWriter bufferOut=new BufferedWriter(outFile);
bufferOut.write(str);
bufferOut.flush();
bufferOut.close();
return true;
}
catch (IOException e){return false;}
}
}
class ReadFile{
public boolean readFile(String path){
int mancnt=0;
int woncnt=0;
float agemony=0;
try{
StringBuffer sb=new StringBuffer();
BufferedReader br=new BufferedReader(new FileReader(path));
String str=br.readLine();
while(str !=null){
sb.append(str);
sb.append("\r\n");
str=br.readLine();
}
str=sb.toString();
System.out.println(str);
String[] st=str.split("\r\n");
for (int i=1;i<st.length;i++){
String stl=st[i];
if(stl.split("\\s{2,}")[1].equals("男"))
mancnt++;
else
woncnt++;
agemony+=Float.parseFloat(stl.split("\\s{1,}")[4]);
}
System.out.println("男员工数:'"+mancnt+"'");
System.out.println("女员工数:'"+woncnt+"'");
System.out.println("平均工资:'"+agemony/st.length+"'");
return true;
}
catch(IOException e){
return false;
}
}
}
public class OperatFile{
public static void main(String[] args){
boolean check=true;
String[] str={
"姓名 性别 年龄 学历 工资 岗位",
"约翰 男 30 硕士 100000.00 银行行长",
"迈克 男 28 博士 200000.00 董事长",
"詹尼 女 24 硕士 150000.00 主任"
};
String path="人员.txt";
WriteFile wf=new WriteFile();
ReadFile rf=new ReadFile();
for(int i=0;i<str.length;i++){
check=wf.writeFile(str[i], path, i);
check=wf.writeFile("\r\n",path,1);
if(!check){
System.exit(1);
}
}
System.out.println("写入文本文件成功!");
rf.readFile(path);
}
}