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 9 of 9

Thread: Buffered writer in a .jar file

  1. #1
    Member
    Join Date
    Feb 2012
    Location
    Azle/Arlington
    Posts
    31
    My Mood
    Torn
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Buffered writer in a .jar file

    I am wondering if it is possible to place a buffered writer in a .jar file to create a .dat file for a high scores table. Can a .jar file edit a .dat file saved in with the classes? and if i can would every computer i play on have to have a jdk or could a computer without a jdk still edit the hiscore.dat file?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Buffered writer in a .jar file

    Are you trying to update the jar file that the code is executing from?
    I'm not sure you can do that. The file to be updated needs to be outside of the jar file.
    You do not need a JDK to execute a java program. You do need a JRE.

  3. #3
    Member
    Join Date
    Feb 2012
    Location
    Azle/Arlington
    Posts
    31
    My Mood
    Torn
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Buffered writer in a .jar file

    What im trying to do is say im playing a number puzzle and i win in 3 moves i want it to save my name, and number of moves. in a .dat file in the .jar file. and then have a seperate method that will read the .dat file and display them if called through most likely a menubar at the top. (i also want to sort them in order of 1st through 10th place) so say i used the buffered writer class would it write the .dat file. (not updating the whole file just the .dat file)

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Buffered writer in a .jar file

    I'm not sure you can update the jar file while executing classes that are in that jar file.
    Where else can you store your data so you can update it?

  5. #5
    Member
    Join Date
    Feb 2012
    Location
    Azle/Arlington
    Posts
    31
    My Mood
    Torn
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Buffered writer in a .jar file

    ok. so could i make it write to the directory location the .jar is at? and then have it called if certain menubutton is clicked. I.E. (c:\Users\"Name"\Documents). What im wanting to do is use a local computer as the main computer and have other players access that file from there computer(all on 1 network) and just rewrite the .dat file. (would that work) I have the working from 1 computer to the next working. and i can write from anycomputer on the network. Im just wondering if i can save the .dat file there and create a buffered writer to update the .dat file. (is there a get location type thing?) so i can make the computer find its location in the harddrive.(like if it is on the desktop it gets the filename for the desktop)

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Buffered writer in a .jar file

    have other players access that file from their computer
    That sounds like a client connecting to a server.
    The server has the .dat file on its local disk. The clients do their accesses to the file by making requests to the server.

  7. #7
    Member
    Join Date
    Feb 2012
    Location
    Azle/Arlington
    Posts
    31
    My Mood
    Torn
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Buffered writer in a .jar file

    kind of like a client and server. but its all in a local network. and if the jar file is moved from the location on the main computer it saves to the documents and becomes a (only 1 user) private hiscore table. (it wouldnt be on the web were u type in the html address and it loads. just when you double click the .jar file it opens and when u win the game it saves to the .dat file.

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Buffered writer in a .jar file

    Are you talking about what MS calls UNC paths? (Uniform Naming Convention) that use \\ at the start?
    The File class supports them and you can access the files just like files at any other path.
    Read the API doc for the File class. It has examples.
    Write a small test program on your computer that uses a UNC path in a File constructor and see how it works.

  9. The Following User Says Thank You to Norm For This Useful Post:

    lorider93p (February 8th, 2012)

  10. #9
    Member
    Join Date
    Feb 2012
    Location
    Azle/Arlington
    Posts
    31
    My Mood
    Torn
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Buffered writer in a .jar file

    I looked it up and I think i can use that for what i want to do. I thanked your post.

Similar Threads

  1. buffered image to RGB array
    By kigroy in forum Java SE APIs
    Replies: 2
    Last Post: October 15th, 2011, 08:08 AM
  2. Manually recoloring buffered images
    By nitrogenFingers in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 29th, 2011, 05:52 PM
  3. help me with my buffered reader please! whats wrong?
    By jeremanalaotao in forum Loops & Control Statements
    Replies: 10
    Last Post: September 6th, 2011, 07:09 PM
  4. Buffered Reader to J Option
    By jk_0821 in forum Collections and Generics
    Replies: 13
    Last Post: July 19th, 2010, 03:14 PM
  5. Buffered Reader is not reading my file properly... HELP!
    By mannyT in forum File I/O & Other I/O Streams
    Replies: 8
    Last Post: November 8th, 2009, 08:14 PM