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

Thread: theory of the netwoprk chat

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

    Default theory of the netwoprk chat

    ok. so me and a c++ writer are thinking of making a network chat server using both c++ and java. I create 1 client for java and he does a c++ and they both read and write to a single text document in a location. so my thing is can we write a file to a location other than just where the .jar file(i use jar to execute my client) ."Before you say dont bother or why" We want to do this just for the joy of doing it. And to test our individual I/O sections of our librarys.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: theory of the netwoprk chat

    can we write a file to a location other than just where the .jar file
    Yes, you can write to any allowed location on the PC with a java program running from a jar file.

  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: theory of the netwoprk chat

    ok sorry been inactive for a bit.
    I even figured out how to write to a different location. Now there is 2 things i would like to know but only 1 on this thread. In buffered write how do you get it to read from a file. then add to the file while keeping what is already written? can someone give me a api or documentation that would help because i cant find anythi

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: theory of the netwoprk chat

    . In buffered write how do you get it to read from a file.
    you don't read with a bufferwriter.
    add to the file while keeping what is already
    One of the file writing classes has a constructor that has an extra boolean parameter the specifies if the file should be appended to instead of overwritten. Check the API doc for how to code it.
    http://download.oracle.com/docs/cd/E...se/6/docs/api/

  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: theory of the netwoprk chat

    Appreciate i been looking and couldnt find a doc for it.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: theory of the netwoprk chat

    couldnt find a doc for it.
    What is the "it"?

    What are the classes you are using?

  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: theory of the netwoprk chat

    oh i just started looking through the api doc and all i found was a append char not a string. and Im working on appending entire strings to the .txt,.dat.or. file im using. and that was a generic it. i meant i had been looking for a api doc that could help and havent found the right 1 yet.

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: theory of the netwoprk chat

    What are the classes you are using?
    There is a file writing class with append mode.

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

    Default Re: theory of the netwoprk chat

    I/O class. (All i know for sure is i have to throw a IOException in any section of the class that uses my buffered writer and readers) (2 seperate methods)

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: theory of the netwoprk chat

    i have to throw a IOException
    Why is that?
    Do you mean you need to write code to catch an exception or to pass the handling of the exception to a higher level?

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

    Default Re: theory of the netwoprk chat

    Im not really sure y i have to the the exception. I was just taught to do that with a bufferedf writer. I will google it and see if im just doing bad programming (highly probable ) Yes i do take better care of my spelling during programming.

Similar Threads

  1. More number theory
    By JeremiahWalker in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 13th, 2012, 01:49 AM
  2. Some help with Java theory?
    By Mudkipers in forum Java Theory & Questions
    Replies: 7
    Last Post: May 12th, 2011, 07:28 AM
  3. API singleton theory
    By dunnkers in forum Java Theory & Questions
    Replies: 10
    Last Post: February 24th, 2011, 12:57 PM
  4. Theory/Question,
    By Time in forum Java Theory & Questions
    Replies: 7
    Last Post: November 9th, 2010, 05:26 PM
  5. Theory Inquiry
    By b_jones10634 in forum JavaServer Pages: JSP & JSTL
    Replies: 2
    Last Post: August 19th, 2010, 08:21 AM