import
import
import
import
import
import
import
import
import
import
public class ReadChar {
//得到字符数的方法;
public static int getCharNumber(String FilePath) throws FileNotFoundException{
File file=new File(FilePath);
int number=(int)file.length();
return number/2;
}
//得到行数的方法;
public static int getLinesNumber(String FilePath) throws IOException{
File file=new File(FilePath);
int number=0;
BufferedReader br=new BufferedReader(new FileReader(file));
for(;;){
if(br.readLine()==null) break;
else number++;
}
br.close();
return number;
}
//将字符写入文件;
public static void writeFile(String FilePath,String content) throws IOException{
File file=new File(FilePath);
BufferedWriter bw=new BufferedWriter(new FileWriter(file));
bw.write(content);
bw.close();
}
//主方法;
public static void main(String[] args) throws IOException {
File file=new File("E:\\计算机文件\\JAVA\\hh.txt");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
char []charArray=new char[300];
int k=0;
for(;;){
int i=br.read();
char c=(char)i;
if(c!='#') {
charArray[k]=c;
k++;
}
else break;
}
br.close();
String readline=new String(charArray);
System.out.println(readline.trim());
writeFile("E:\\计算机文件\\JAVA\\hh.txt",readline.trim());
int n=getLinesNumber("E:\\计算机文件\\JAVA\\hh.txt");
System.out.println(n);
int n1=getCharNumber("E:\\计算机文件\\JAVA\\hh.txt");
System.out.println(n1);
}
}