Login and register from txt file using java | fun with java #1

Поделиться
HTML-код
  • Опубликовано: 3 окт 2024
  • This video basically an implementation to write in txt (text) file and retrieve its data in a formal way. Enjoy :)
    Got stuck somewhere?
    Download the source code: github.com/Nil...
    Explanation
    8:13
    addData :
    1) Fetch file
    2) skip no. of lines already exists
    3) write batch files
    (you should skip checkData, it only work for single batch of data)
    22:27
    logic:
    working:
    1)loop through each data batch
    2)check user and password if match, then print found and exit
    3)if last data batch then print not found and exit
    4)skip lines that are not username and password i.e email, blank line,etc.
    1) increments = number of data in single batch
    exp: loop through no. of data batches
    2) check for incorrect user = increments - 1
    exp: check if current batch is the last batch of entire document and no user and password matched.
    3) lines to skip = k = increments - data lines other than user and password
    exp: we need only user and password to check and skip other lines of single batch
    variables values need to be adjusted:
    i+= [increments] (no. of data batch)
    ln-[increments - 1] (no. of lines inside each batch - 1)
    k till= [k] (no. of lines to skip)
    batch example:(no. of lines inside each batch should be equal)
    ---------------------
    Username:youtube
    password:pass
    email:mail@mail.com
    Username:stack
    password:overflow
    email:stack@mail.com
    ----------------------
    no. of data batches = 2
    no. of lines inside each batch (4) - 1 = 3 (except last batch,including blank line)
    no. of lines to skip = 2 (except last batch, including blank line)
    audio credit: www.bensound.com

Комментарии • 84

  • @dewesh3312
    @dewesh3312 5 лет назад +4

    😍 thanks sir . Your video is easily to understood by another youtube video. I wait More video upload

    • @rapidclicks2809
      @rapidclicks2809  5 лет назад +1

      Stay tuned we will upload more soon... :)

    • @edgarcalochcampos1930
      @edgarcalochcampos1930 5 лет назад

      could you tell me what is that another video, please?

    • @rapidclicks2809
      @rapidclicks2809  5 лет назад

      @@edgarcalochcampos1930 if you could suggest one :)
      ...
      I'll try

  • @dkpelect
    @dkpelect 9 месяцев назад

    Exactly what I was looking for ! Thanks

  • @abdullahhani672
    @abdullahhani672 4 года назад +3

    11:30 (add data)
    19:55 (final)

  • @catdragon2096
    @catdragon2096 3 года назад

    thanks your video because have your video I known about "substring" . Hope you can produce more videos. Best of good luck. Thank you again

  • @limlw1068
    @limlw1068 3 года назад +2

    Sir, it always shows this error
    Exception in thread "AWT-EventQueue-0" java.lang.StringIndexOutOfBoundsException: String index out of range: -9
    Even if I added
    for(int k=1;k

  • @PianoFNBR
    @PianoFNBR 2 года назад +1

    HI I am gettin this error Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException when inputting the wrong username or password it works perfect when the username and password are correct but does this if they are wrong

  • @GhosTzinnX
    @GhosTzinnX Год назад

    mermão, muito complexo, mas me ajudou em algumas partes, parabéns pelo trabalho! Congratulations for your job!

  • @MorsHs
    @MorsHs 4 года назад +1

    can you redo this? the more proceed without deleting unnecesarry things makes me confuse more ty

  • @s.meiespina4954
    @s.meiespina4954 9 месяцев назад

    can i ask what code do i put to reject "register" button when the user does not input anything to the fields?

  • @mdraiyanalam5612
    @mdraiyanalam5612 4 года назад +2

    it would be better if you lead the source code..

  • @roro1999aa
    @roro1999aa 3 года назад

    can I know why you use RandomAccessFile instead of BufferedWrite?

  • @Areejmub
    @Areejmub 2 года назад

    The rw in add data what is it for ? Or who?

  • @Trexor6940
    @Trexor6940 3 года назад

    On the checkData function why do I kept on getting wrong user/passwword even though it has the right username and password

  • @jughnnneeelll
    @jughnnneeelll 3 года назад

    Hello sir! can we also use this without the jframe?

  • @calisthenicsguy0518
    @calisthenicsguy0518 3 года назад

    Can you make, login form like that in console ???,
    Im new to programming and i just want to learn how to create Verifying login form
    with txt file in java

  • @sameerulhaq4066
    @sameerulhaq4066 2 года назад

    Sir if we add multi user like admin and user then how will we do if you can make video it will be helpful or tell me in comments where to edit it

  • @Manisha0803
    @Manisha0803 3 года назад

    Is text file using indexing technique?

  • @edgarcalochcampos1930
    @edgarcalochcampos1930 5 лет назад +1

    Hi! Idk if you can help me out, i have a doubt about the line you wrote in min 25:02 (the for). What is it used for, and should i write it too if i'm just receiving user and password?

    • @rapidclicks2809
      @rapidclicks2809  5 лет назад +2

      @Edgar, as we are searching for the correct password for user that's why we need to check them only.
      And the rest of line should be ignored i.e email and the blank line.
      And if you are not giving any mail and blank lines after every user than you don't need to add that loop :)

    • @edgarcalochcampos1930
      @edgarcalochcampos1930 5 лет назад

      @@rapidclicks2809 cool, thank u so much!

    • @edgarcalochcampos1930
      @edgarcalochcampos1930 5 лет назад

      ​@@rapidclicks2809 Hey there, I'm sorry to bother you again but i've tried to look for info from everywhere and i haven´t found a solution to my problem yet ): ... Do you know if there´s a way to import data from a textfile (that has its data in different lines as in this video) to a jtable with 2 columns? I've seen some people using the method split but it's not that useful when you are trying to read from different lines... I would appreciate any help.

    • @rapidclicks2809
      @rapidclicks2809  5 лет назад +1

      @@edgarcalochcampos1930 hey, I think above method(video) will do the trick to copy data to jtable columns like just assigning values...
      As you have to only jump to lines and substring the amount of string you need.
      ...
      IDK if this will help you.

  • @dlovanwasmanhammad3943
    @dlovanwasmanhammad3943 4 года назад +1

    i dont understand how count lines can you help my??

    • @rapidclicks2809
      @rapidclicks2809  4 года назад

      CountLine method just check if there is a new line, and increment the variable.
      Later we use that to skip the no. of lines to add new values, or to get an estimate to which how far we have to search for values(username/password).
      IDK if this is answer of your question

  • @drinking522
    @drinking522 4 года назад

    can you do a video of how you can view the data in textfile delete all this step by step again

  • @imadeddineterkmani9145
    @imadeddineterkmani9145 4 года назад +1

    Thanks 🧡

  • @woonjielai2163
    @woonjielai2163 4 года назад

    can u teach how to modify the value? for example,if i want to reset the password,pls reply as soon as possible,thx

    • @rapidclicks2809
      @rapidclicks2809  4 года назад

      Hey, value of txt files can only be edited by creating a temporary txt (using fileWriter).
      1) create a new temp txt with file writer
      2) copy all data (skipping the one to be modified)
      3) add the modified user data at the end.
      4) write the temp data in original txt and delete temp.
      This technique is too bad if data scale is large. So JSON format is used and is quite simple to do such operations, I have a video about it, that'll help

  • @lornaaban389
    @lornaaban389 4 года назад

    THANK YOU VERY MUCH :)) Ill ask a thing. Is it possible to add a delete username and password function?? If yes how?? Can you help me out :(( much appreciated!!! Ive Already subscribed!!

    • @rapidclicks2809
      @rapidclicks2809  4 года назад

      Hey @Lorna Aban,
      Java handles txt files as stream, that only write and/or replace existed.
      *you cannot delete any character
      (In my knowledge)
      - you can write a blank space at that line
      Or
      just create a new temporary file and paste all data and copy rest of needed things to original file (most people prefer this).

    • @lornaaban389
      @lornaaban389 4 года назад

      @@rapidclicks2809 Thanks! I currently studying the method which includes temp files :)) thank you

  • @louissueno4721
    @louissueno4721 2 года назад

    I've already done everything that was shown till this part 14:24 but I can't open the dialog message. Could anyone please answer this, I badly need the answer.

    • @louissueno4721
      @louissueno4721 2 года назад

      To be clear, I've already finished the whole code in this video but, the dialog message still can't seem to appear.

  • @vithusas4024
    @vithusas4024 4 года назад +1

    Can you do login/register but using json File?

    • @rapidclicks2809
      @rapidclicks2809  4 года назад +1

      Yes, and it will be easy and shorter than this video :)

  • @christopherliuwell81
    @christopherliuwell81 2 года назад

    Thanks A Lot 👍

    • @karuchiu
      @karuchiu 2 года назад

      I lost it at the countLine() method.. can you help?

  • @dharapatel5571
    @dharapatel5571 4 года назад

    Thank You So Much..

  • @mosesglitch3110
    @mosesglitch3110 3 года назад

    Thank you so much

  • @skysorcerer
    @skysorcerer 3 года назад

    Probably that would be easier to crack since you literally just have to open the text file and then all of the login credentials are there.

    • @foca2002
      @foca2002 2 года назад +1

      Not to be used in a production environment. But if you use some kind of hash and salt is as secure as Linux or windows.

  • @drinking522
    @drinking522 4 года назад

    sorry for asking again, if i want to show message dialog after data added where i should input this code?

    • @drinking522
      @drinking522 4 года назад

      and also if data not inserted

    • @rapidclicks2809
      @rapidclicks2809  4 года назад

      @@drinking522 at 10:07 below line 58, print 'added' and inside catch condition print 'failed'

    • @drinking522
      @drinking522 4 года назад

      @@rapidclicks2809 can you type the full code here

  • @jameszagada8963
    @jameszagada8963 4 года назад

    My button for loggin in doesn't work with "logic". Adding the forloop will make the button useless (nothing happens). Is there any idea?

    • @rapidclicks2809
      @rapidclicks2809  4 года назад

      hey James,
      you might misplaced function calls, if haven't solved yet download the source code, link in the description.

    • @katlego5351
      @katlego5351 4 года назад

      i am having the same problem
      even after downloading the source code

    • @limlw1068
      @limlw1068 3 года назад

      @@katlego5351 Hello, I have the same problem as you, did u solve it? if yes, could u please tell me how to solve it?

    • @katlego5351
      @katlego5351 3 года назад

      @@limlw1068 hi
      I think i watched a different video , it was last year so I don't remember sorry

    • @limlw1068
      @limlw1068 3 года назад

      @@katlego5351 okay, thanks for the reply, still struggling with this problem......

  • @yq5687
    @yq5687 4 года назад

    can do the same video using eclipse ? i thought a bit different when i run it

    • @rapidclicks2809
      @rapidclicks2809  4 года назад

      @Y Q, use of JFrame will only be changed and the rest of the things remain same, you just need to bind the function call to their jFrame elements :)

    • @yq5687
      @yq5687 4 года назад

      @@rapidclicks2809 alright thx ^ ^

  • @Ofeklevi71
    @Ofeklevi71 4 года назад

    How will I do the file f = new file (path) on mac

    • @rapidclicks2809
      @rapidclicks2809  4 года назад +4

      Use '/' instead,
      File f = new File("/Desktop/Java.txt");

  • @aisha2991
    @aisha2991 4 года назад

    Can anyone help me? Why mine have the "string index out of range: -9"? Error? I can't login and register
    I even copy the exact coding from the source code but even the Joption pane isn't showing. It keeps on saying AWT-EventQueue plus the -9 string.

    • @rapidclicks2809
      @rapidclicks2809  4 года назад

      Hey Aisha,
      At 24:45 , had same issue, it happens when FileReader try to access a non-existent line, it can be fixed by changing the iteration count according to txt data,
      check my reply on Melson's comment that'll help. :)

    • @limlw1068
      @limlw1068 3 года назад

      Hello, have u solve the problem?it seems like Melson's comment doesn't exist. If you have solved the problem, can you please tell me?

    • @hanzayaim8412
      @hanzayaim8412 Год назад

      any solution for this?

  • @drinking522
    @drinking522 4 года назад

    can i know what shud i type for the login button if after password is match i want to go to next frame

    • @rapidclicks2809
      @rapidclicks2809  4 года назад

      Inside if statement, after "password matched" line (LOC=103) call another frame. i.e, jframe2.setvisible()=true;

    • @drinking522
      @drinking522 4 года назад

      @@rapidclicks2809 isit like this ?? for example the frame i want is register.java
      register r = new r();
      r.setVisible()=true;

    • @drinking522
      @drinking522 4 года назад

      @@rapidclicks2809 for example my frame call register.java so i type there after password matched line before break; line
      register.setVisible(true); like this?

    • @rapidclicks2809
      @rapidclicks2809  4 года назад +1

      @@drinking522 , It should be like this-
      JFrame f = new JFrame();
      f.setSize(500,500);
      f.setVisible(true);

  • @christianwkm
    @christianwkm 4 года назад

    Hello, the source code in the description isn't working. Can you upload it on pastebin?

    • @rapidclicks2809
      @rapidclicks2809  4 года назад

      Isn't working? What does it say?

    • @christianwkm
      @christianwkm 4 года назад

      @@rapidclicks2809 the file contains classes only. It doesn't contain the .java code

    • @rapidclicks2809
      @rapidclicks2809  4 года назад

      Re-uploaded!

    • @christianwkm
      @christianwkm 4 года назад

      @@rapidclicks2809 thank you sooo much

  • @exposureexp7850
    @exposureexp7850 Год назад

    if i choose a combo box then how would I save in text files, as you used *tfusr.setText("");*
    so how would I do for combobox? *tfcombobox.setcombo("")?
    @RAPIDCLICKS

  • @stephaniehartlauronbonganc6513
    @stephaniehartlauronbonganc6513 3 года назад

    good day sir, I tried to follow your tutorial however I always get a problem on the logic it always show this "AWT-EventQueue-0" java.lang.StringIndexOutOfBoundsException: String index out of range: -3

    • @rapidclicks2809
      @rapidclicks2809  3 года назад

      It happens if number of lines in single batch changed, I have added explanation in the video description, that might help.