java读取文件单词_Java读入一个txt文件,并且从txt文件中的某一个单词开始读里面的数字...

例如我的txt文件是okokokokokokbegin123213okok12412551endokok我想读入从begin开始的数字和字符然后到end结束我已经会读入txt的程序如何修改才行publicstaticvoidmain(String[]args)...

例如我的txt文件是 okokokokokokbegin123213okok12412551endokok

我想读入从begin开始的数字和字符 然后到end 结束 我已经会读入txt的程序 如何修改才行

public static void main(String[] args) {

// TODO Auto-generated method stub

File file = new File("C:/zc.txt");

BufferedReader

reader = null;

String tempString = null;

int line =1;

try

{

System.out.println("以行为单位读取文件内容,一次读一整行:");

reader = new BufferedReader(new

FileReader(file));

while ((tempString =

reader.readLine()) != null) {

System.out.println("Line"+ line + ":"

+tempString);

line

++ ;

}

reader.close();

} catch

(FileNotFoundException e) {

// TODO

Auto-generated catch block

e.printStackTrace();

} catch (IOException e)

{

// TODO Auto-generated catch

block

e.printStackTrace();

}finally{

if(reader != null){

try {

reader.close();

} catch (IOException e)

{

// TODO Auto-generated catch block

e.printStackTrace();

}

}

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值