Added: 2 years ago
From: thenewboston
Views: 71,376
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:

All Comments (111)

Sign In or Sign Up now to post a comment!
  • 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.

  • 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.

  • @Tinzert Store it in a variable and then convert it to a int, make temp variables to add them!

  • @Tinzert

    int sum=0;

    while(x.hasNextInt){

    sum+=x.nextInt();

    }

  • "Joe Doe". This is why I watch your Java tutorials, Bucky.

  • My name's Mike Ike.

  • What do you do if the file is a table with some blank elements. so like

    a b c

    0 3

    3 4 5 3 4

    so how do I make sure that it only puts in a, b or c the values in their respective columns, anyone know?

  • How do you get multiple records? everytime I run mine it just replaces the first one with the new one

  • Is there a method for updating files in java?

  • why doesnt it recognise symbol Scanner???

    INTERNAL_ASSESSMENT/Internal_A­ssessment_18_10.java [215:1] cannot resolve symbol

    symbol : class Scanner

    location: class INTERNAL_ASSESSMENT.Internal_A­ssessment_18_10 private Scanner x;  ^

  • IS IT POSSIBLE TO USE ANOTHER METHOD BESIDES "RECORD ", OR WOULD IT EVEN BE NECESSARY.

  • Exception in thread "main" java.util.NoSuchElementExcepti­on at java.util.Scanner.throwFor(Sca­nner.java:838) at java.util.Scanner.next(Scanner­.java:1347) at H81_reading_from_file.readfile­.readFile(readfile.java:27) at H81_reading_from_file.apples.m­ain(apples.java:9)

  • A few videos ago there was 30000+ views. Now there are 50000+ views. bunch of lazy people r trying to get to the good parts only!

  • Sorry, The Program Could Not Find The File Specified.

    Exception in thread "main" java.lang.NullPointerException at readfile.readFile(readfile.jav­a:16) at launcher.main(launcher.java:6) ?!?!?!?!?!?!?!?!??!!?!?!?!?!?!­?!?!?!?! I copied this exactly -.-

  • @Allenmarxchannel couldn't find the file trying to read

    

  • "*cough* ah, whooping cough. Lol, I love your randomness in all of these! Thanks a bunch for all these videos, they're really helpful!

  • thanks!

  • Almost there :D

  • great tutorial as expected. wondering if you're covering vectors also... but i think its all GUI from here

  • Another way to get file contents:

    while (x.hasNextLine()) System.out.println(x.nextLine(­));

  • @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.

  • I wonder if he'll ever cover why it always says that the default package is discouraged. Lets use a different package, bucky.

  • So x.hasNext() looks for the next line and x.next looks for the next word, right? Seems obvious based on the result but he never made that clear.

  • @prebek i think hasnext looks to see if there is another word not line... Im not sure though

  • @mattrocks182 oh ok, i think you're right, thanks

  • it think we should put the try catch in the main too. When i trigger the error in the readfile class, it catch it but then the open read and close from the main class display errors too. 

  • I have a small question. If the hasNext() method in the while returns only if there is still at least one token to read, but you use 3 tokens in a row on your code without rechecking with hasNext(), wouldn't it cause problems?

  • aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa­aaa fuck 81 tutorials in a row and that bastard is making more

  • a, b, c, d, f, g?

    Lol, i made it to the 81st tutorial...hard work ya know...

  • @FreePKMNWalkthroughs a, b, c, d, e, f >_< lol

  • @puimiu Shut up.

  • YOU SHOULD START A SCHOOL!!!

  • @imtihanahmed seconded ^

  • my teacher never teaches. it is from u that i have learned arrays and arraylists, and files. THANK YOU.

  • You talk so Good damn fast for a video tutorial, learn to speak more clearly and rarely. You could have made the tutorial a little longer then 7:51.

  • Excellent tutorial dude, keep up the good work!

  • if you wanted to keep the values for a,b, and c so that you keep everything read from the file, you'ld use arrays a[] b[] c[] (with appropriate sizes) and iterate through each element in the arrays. You could then do a search a name or number or whatever you want to do with the data.

  • How would you read in from a csv file?

  • thanks dude! :) owe you one, keep us posted!

  • can someone pllzzzz tell me how can i handle the context of a file? for example lets say taht i want to find someone whith his last name and print his age . :( plzzz

  • String a  = x.next();

    in place of that can i use like:

    int a = x.nextInt(); ???

    will this work??

  • THANK YOU

  • Hey bucky i was just wondering how does the method x.next() know to assign each part of the record first to a, then b, and then to c. I just thought if you're assigning x.next() to all three a, b , and c wouldn't all of them be the same?

  • @sebg18 I believe it's because the spaces separates them. It reads the text and goes on to the "next()" part of the document with text in it. (Might wanna look that up to confirm it, but from what I've tested, that's true.)

    Hope that helps!

  • How can I get my Java program, built in eclipse to ask for a command line argument before running or to just run in the cmd?

  • thanks a lot!

    I loved it!

  • hey bucky how comes you didn't teach us about fileinputstream and bufferedinputstream and datainputstream!?

  • your the best dude!

  • Bucky, where should i save the file? I tried the src and the bin folders of my project folders, but the system still can't find the file

  • do you have any tutorials on how to search for a word in a file???

    ie if you have:

    20 bucky roberts

    60 joe doe etc in a file and we want to find bucky

    how do we do that?

  • i am stick with these tuts from the begging and have 6 more to watch as well

  • how can you create two file and move the data from one file to another like to tranfer all the data from chinese.txt to another file that you created

  • @stargem16 make a new file using formater(tutorial 79 if i remeber right) ... read the data from the first file (this one)... write them in the second(tutorial 80) wish that helped

  • thank you!The Scanner-method is very useful!

    Keep it up!

  • this really helps in my assignment..

  • hi,

    how can I save the position(x,y) of a movable thing (=>x and y change) to a file.

    I ask, because I am creating a game and i want to save the position of the charakter and load it later again.

    THX

  • @MurayTheBanana check his 80th tutorial on how to write to files and his 75th / 76th (I think) tutorials on how to register x and y positions with the mouse. 1 + 1 = 2:p

    Just store those positions in the text file and you're done ;) load em whenever you like

  • What if you wanted to take those strings and store whole file into an arraylist? how would you go about doing that?

  • Great vid and why did u name the the things in chinese.txt this –––>

    20 bucky roberts

    60 joe doe

    50 mike ike

    49 sis priss

    hilarious! anyway, great tut.

  • fantastic tutorials :D

    when you make a public sessions? or if you make where?

    im from Portugal, if possible make here :D

    thanks for all

  • how do you read 1line of a hole txt file with scanner

  • what does printf do? compared to print and println

  • @LearnTechTv it just prints out a string differently. some people think its more organized idk

  • Great tutorial but I have one question...

    How do I tell Java to skip a line each time I use the .format() method to write to the file???

  • @ bucky , if u read this there's in issue about this tutorial , a couple of us have been havin , its posted in ur java forum , can u please check it out .

    thanks

  • @SInnerMario Did he help u with the solution to this problem?

  • thanks

  • Where did you save the .txt file?

  • @FrimmiSigurds wherever you want...

  • thank's man !!

  • Thank you so much Bucky! I really appreciate these Tutorials. You've helped me out with my programming class and its rly coming in handy this last part of the year. Thank you so much i really appreciate it ! :D

    ~Marc

  • 100% more helpful than my university lab sessions. Thank you man! :)

  • Excellent tutorial compared to paid online tutorials

    and I have one question if u down load a mysql non-installer zip file how we can install it and how we can start the server service

  • thx for heping people and me You ar great guy..

    Greetings from Poland

  • How do you add another Record ?

  • if i give like System.out.println(a);

    it is printing the whole line can i know why

  • You are the best! Awsome!!

  • Thanx Bucky for everything. awesome tutorials. I have a doubt. what if we want to read suppose all XML files. does "*.xml" does work ???? Thanx in advance.

  • @srikanthtmt Why not try it?

  • Bucky I think you are the best. Coming straight out of Jamaica.

  • you are nuber one mr thenewboston

    Thank-you so much ,y are nice...

    You can show we the : JDBC ,web ,please !

    Thank-you

  • ya jdbc and web would be helpful.

  • ps. is there a tutorial for importing and interacting with home drawn images ie user designed GUI's?

  • Top Quality tutorials, please keep doing them

  • dude, i'm the kind of person, that uderstand way more if someone explain me, than reading the example, thnx, you are a great help, i need something like this for my project.

  • bucky your the man keeeeeep makin those tuts

  • still confused as a mofo

  • wow how come your java tutorials are a lot more than c++?

  • win

  • great tuts bucky

    keep em comin ;p

  • bucky, why dont you use a BufferedReader?(if u did i didnt watch whole vid)

  • Scanner and BufferedReader are almost the same, it doesn't matter wich he uses..

  • awesome!

    please keep them coming..

    Can You make some videos about applets?

  • nyyyyyycccc

  • thank ya

  • ttt

  • cool :) i dont use java but ur very cool with these tuts :) 4 me the comp tut was cool :D

  • Thanks Bucky!!!

  • nice

  • I love your tutorials! Keep them coming.

  • AAAH! UUUH !!

Loading...
Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more