This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

location of save

 
Nikos Stavros
Ranch Hand
Posts: 243
Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where does the ObjectOutPutStream save by defult
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To construct an ObjectOutputStream, you need to provide an OutputStream, which -unless you're using ByteArrayOutputStream- is based on a File object. That File object specifies where the OOS will write to.
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nikos Katsikanis:
where does the ObjectOutPutStream save by defult


There is no default. If you look at the API docs for ObjectOutputStream, you will see that the no-arg constructor is protected. This means it can only be used by subclasses which will then provide the location or other means to specify it. If you are creating an ObjectOutputStream directly, you must use the constructor that thakes a OutputStream as a parameter. I suggest that you look at the API link in my signature and become familiar with the information there. It is an invaluable tool as a Java programmer.

Layne
 
Layne Lund
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
To construct an ObjectOutputStream, you need to provide an OutputStream, which -unless you're using ByteArrayOutputStream- is based on a File object. That File object specifies where the OOS will write to.


That isn't entirely accurate. I can think of several ways to obtain an OutputStream that isn't based on a File object:

  • System.out
  • Socket.getOutputStream()
  • URLConnection.getOutputStream()
  • PipedOutputStream


  • Since you can extend OutputStream, there are plenty of other options as well with a custom implementation. I can imagine a lot of situations where OutputStream is not based on an underlying file.

    Layne
    [ March 07, 2006: Message edited by: Layne Lund ]
     
    Nikos Stavros
    Ranch Hand
    Posts: 243
    Python
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    ok I'll have a look at that, although sometimes I can't understand all the jargon on the API!

    thanks for help guys
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic