Java Programming Tutorial - 81 - Reading from Files
Top Comments
Video Responses
All Comments (111)
-
I hear crickets in the background. Are you programming in the woods? Right on!
-
can you use this same method to read a Config file?
-
How can I open a file that i have created with Formatter to store more values???
-
My error (see my comment below) only occurs when I have only 1 number, 1 first name, and 1 last name. When I added more numbers and names to my file, it printed out the correct stuff.
-
I'm getting an error involving my readFile method:
Exception in thread "main" java.util.NoSuchElementExcepti
on at java.util.Scanner.throwFor(Unk nown Source) at java.util.Scanner.next(Unknown Source) at readfile.readFile(readfile.jav a:24) --> This line is the declaration of c. at apples.main(apples.java:5) --> This line calls the method readFile. -
-
@Tinzert Store it in a variable and then convert it to a int, make temp variables to add them!
-
My program NEVER writes, what's in the class. I tried many things but nothings working. can so help?
-
Say I read a number from a file -- how would I add those numbers together? I saved the read data as int variables but for some reason I get an error "unexpected type" when they should be treated as regular variables.
-
@nWANTED yes this is far better compared to hasNext() because you read the whole line it is not confusing is it like wen u print the whole line, println but i think hasNext() is good to cover first in tutorial. java must be having many methods to read a file i guess.
Another way to get file contents:
while (x.hasNextLine()) System.out.println(x.nextLine());
nWANTED 7 months ago 19
great tutorial as expected. wondering if you're covering vectors also... but i think its all GUI from here
ojstrike 7 months ago 6