hello guys,
well basically i have zero java knowledge, so don't mind me asking such kind of dumbass question( to you but not to me lol)
so, i have a .txt file in which there is a number in such line (for example, 0 and 1)
i want to print out "yes" if all numbers are 0,
print out "no" if all numbers are 1,
and print out nothing if the numbers are not the same, i.e. some are 0 and some are 1.
how can i do it?
thanks

There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in helping you cheat or doing your homework for you.

DaniWeb Member Rules (which you agreed to when you signed up) include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
http://www.daniweb.com/community/rules

Post what you have done so far and someone will help you from there.

to add to James' point: if you have 'zero knowledge of Java', you should first 'gain knowledge of Java' instead of thinking it's a good idea to start with I/O tasks in Java.

just look at it this way: if you hire a contracter to build you a house, would you believe him to know his job if he starts with creating a roof mid-air, or would you rather think him to be a professional if he starts with the foundations ?

and to add to both of them ^^

Using Scanner in java, you can read text files, and do it by reading an entire line from the file at a time
Once you have a line available, you can check if it contains 0, if it doesn't you print yes, if it does, you print no

... except ...
Scanner is an overkill way to read lines from a text file
and
the algorithm you describe is in no way a solution to the requiremnt as posted.

Hi James,
Why would it be an overkill when having a couple of lines in a file? You don't really need good performance for that?
Also, why wouldn't it work if you just read a line as a string and see whether it contains "0" ?

To read lines, just use a BufferedReader's readLine() method. Simpler, handles exceptions properly, no risk of side effects.

Did you consider the case where there are multiple 1's and multiple 0's?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.