aspose file tools*
The moose likes Beginning Java and the fly likes location of save Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "location of save" Watch "location of save" New topic
Author

location of save

Nikos Stavros
Ranch Hand

Joined: Feb 24, 2006
Posts: 243

where does the ObjectOutPutStream save by defult


Jesus lives
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42281
    
  64
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.


Ping & DNS - my free Android networking tools app
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
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


Java API Documentation
The Java Tutorial
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
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

    Joined: Feb 24, 2006
    Posts: 243

    ok I'll have a look at that, although sometimes I can't understand all the jargon on the API!

    thanks for help guys
     
    It is sorta covered in the JavaRanch Style Guide.
     
    subject: location of save