读取txt字符package com.xahl.io;
import java.io.*;
public class tongji {
char c[] = new char[100];
int t = 0;
public void tongji() {
for (int i = 0; i < 100; i++) {
if (c[i] == 'e') {
// c[i] = 'A';
t++;
}
}
System.out.println("这个文件中有" + t + "个e");
}
pu...
package com.xahl.io;
import java.io.*;
public class tongji {
char c[] = new char[100];
int t = 0;
public void tongji() {
for (int i = 0; i < 100; i++) {
if (c[i] == 'e') {
// c[i] = 'A';
t++;
}
}
System.out.println("这个文件中有" + t + "个e");
}
public tongji() {
}
public void connection() {
try {
File f = new File("C:/Documents and Settings/menjie/桌面/11.txt");
FileInputStream in = new FileInputStream(f);
InputStreamReader ir = new InputStreamReader(in);
ir.read(c);
} catch (Exception e) {
e.printStackTrace();
}
}
public void push() {
try {
File fc = new File("C:/Documents and Settings/menjie/桌面/2.txt");
FileOutputStream out = new FileOutputStream(fc);
OutputStreamWriter ow = new OutputStreamWriter(out);
ow.write(c);
ow.close();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
tongji k = new tongji();
k.connection();
k.tongji();
k.push();
}
}
本文档为【读取txt字符】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。