BufferedReader - 帮助!!! [英] BufferedReader - Help!!!

查看:83
本文介绍了BufferedReader - 帮助!!!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我正在努力应对有关从txt文件读取和写入的新知识的挑战。


现在我刚刚了解了Scanner类,我可以使用delimiter(,)来创建令牌。但是,如果txt文件在第一行的每个标记之前有一个标题,那么如何检查你想要它说什么以及它说的是真的,因此继续下一行是标记所在的位置。我承认这是作业,但我花了整整一天(​​我没有)在一个问题上。请有人帮助我。

Hi all,

I''m struggling with a challenge on new learnings about reading and writing from a txt file.

Now I have just learnt about the Scanner class and i can usedelimiter (",") to create tokens. But what if the txt file has a heading before each token on the first line, how do you check that what you want it to say and what it does say are true and therefore go on to next line which are where the tokens are. I do admit this is homework but i have spent a full day (which i haven''t got) on one question. please somebody help me.

展开 | 选择 | Wrap | 行号

推荐答案

BufferedReaders在幕后阅读更多内容可以知道。为什么不只是

读取行(使用BufferedReader)?第一行是池名称,

其他行是国家/地区的得分。一行只是一个字符串,它有一个

漂亮的split()方法可用。


分开逗号周围的其他行;该方法返回一个字符串数组。

该数组中的第一个元素是国家/地区的名称。其他条目

表示可以使用Integer类中的方法

从String转换为int的分数(查看Integer类的API)。


你不需要一个扫描仪,当然也不需要与一个

BufferedReader对象结合使用。


亲切的问候,


Jos
BufferedReaders read more behind the scenes that you can know. Why not just
read lines (using that BufferedReader)? The first line is the pool name and the
other lines are the score of the countries. A line simply is a String and it has a
nice split() method available.

Split the other lines around the comma; that method returns an array of Strings.
The first element in that array is the name of the country. The other entries
represent the scores that can be converted from a String to an int using a method
from the Integer class (check out the API for the Integer class).

You don''t need a Scanner for this, most certainly not when combined with a
BufferedReader object.

kind regards,

Jos


感谢您的建议 - 我担心我会被建议使用其他方式,但我必须表明我已经学会了我的教训!但是教科书并不太擅长教学!!


这里是我的更新代码,我对此有点自信,但我得到了一个)预期的编译错误。


任何人都可以看到任何东西吗?


任何建议在哪里放置else语句以及如何放入其中以安全地结束程序如果声明是假的?

Thanks for your advice - i was worried i would be advised to use other ways but i have to show that i have learnt what i was taught! But the textbooks are not too good at teaching!!

here''s my updated code, i am a little more confident with this but I am getting a ) expected compiler error.

anyone see anything please??

Any suggestions where to put the else statement and also what to put in it to end program safely if if statement is false?

展开 | 选择 | Wrap | 行号



here'这是我的更新代码,我对此更有信心,但我得到了一个预期的编译器错误。


有人看到了什么吗?
here''s my updated code, i am a little more confident with this but I am getting a ) expected compiler error.

anyone see anything please??



我确定你的编译器说了更多:它检测到语法的行

错误和比描述性更强的消息你告诉我们了请不要让我们猜错,但要逐字复制错误诊断信息,这样我们就可以看到

你看到了什么。


亲切的问候,


Jos

I''m sure your compiler said some more: the line where it detected the syntax
error and a bit more descriptive message than you''ve told us. Please don''t make
us guess but copy the error diagnostic message verbatim so that we can see
what you saw.

kind regards,

Jos


这篇关于BufferedReader - 帮助!!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆