Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: java password

  1. #1
    Junior Member
    Join Date
    Jun 2009
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question java password

    Can someone make a program that creates a simple 4 digit password for a text file, and notate what every line of code does.


  2. #2
    Member Fendaril's Avatar
    Join Date
    Nov 2008
    Posts
    54
    Thanks
    7
    Thanked 6 Times in 5 Posts

    Default Re: java password

    Hello pwngrammer and welcome to the java programming forums. I think this belongs in the java program collaboration section located here: Project Collaboration - Java Programming Forums

    I would help you out here but I don't know much about file I/O in java. Sorry .

  3. #3
    Member Truffy's Avatar
    Join Date
    May 2009
    Location
    Philippines
    Posts
    93
    Thanks
    2
    Thanked 9 Times in 7 Posts

    Default Re: java password

    welcome to the java programming forums.

    it thinks this will help you. it can give you ramdon numbers, so it can be used for password.

    http://www.javaprogrammingforums.com...m-numbers.html

    bout writing in a file, hmm, try to search for it. kinda busy.
    but i will try to keep in touch.

    Cheers,
    Truffy

  4. #4
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 286 Times in 225 Posts
    Blog Entries
    4

    Default Re: java password

    Hello pwngrammer, welcome to the forums

    Don't forget about our Tips & Tutorials forum. There are lots of code snippets in there:

    Java Tips & Tutorials - Java Programming Forums

    This is what you need for writing a file:

    http://www.javaprogrammingforums.com...sing-java.html

    I will write an example application for you ASAP...
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  5. #5
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 286 Times in 225 Posts
    Blog Entries
    4

    Red face Re: java password

    Quote Originally Posted by Fendaril View Post
    Hello pwngrammer and welcome to the java programming forums. I think this belongs in the java program collaboration section located here: Project Collaboration - Java Programming Forums

    I would help you out here but I don't know much about file I/O in java. Sorry .
    That forum is more for projects that we work on as a team. pwngrammer is just being lazy and asking for someone to do the work for him

    Try this pwngrammer:

    import java.io.*;
    import java.util.Random;
     
    public class Pwngrammer {
     
        /**
         * JavaProgrammingForums.com
         */
        public static void main(String[] args) throws Exception {
     
            Random r = new Random();
     
            Writer output = null;
            File file = new File("PasswordFile.txt");
            output = new BufferedWriter(new FileWriter(file));
     
            int password = 0;
     
            for(int a = 0; a < 4; a++){
                password = (int)(9.0 * Math.random()) + 1;
                System.out.print(password);
                String myString = Integer.toString(password);
                output.write(myString);
            }
     
            output.close();
            System.out.println("");
            System.out.println("Password written to file.");
     
        }
    }
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  6. #6
    Junior Member
    Join Date
    Jun 2009
    Posts
    21
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: java password

    Im doing this one for fun now. Thank you to all of you for helping me out with both my programs. This one has a problem. Cannot find symbol-class Writer

  7. #7
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 286 Times in 225 Posts
    Blog Entries
    4

    Default Re: java password

    Quote Originally Posted by pwngrammer View Post
    Im doing this one for fun now. Thank you to all of you for helping me out with both my programs. This one has a problem. Cannot find symbol-class Writer
    There are no errors in that code. It was tested before posting. Did you include the imports? import java.io.*;
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

Similar Threads

  1. Java password generator program to generate 8 random integers
    By Lizard in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 16th, 2009, 07:49 AM