This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Distributed Java and the fly likes Serialization location Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Serialization location" Watch "Serialization location" New topic
Author

Serialization location

Eric Larsen
Ranch Hand

Joined: Mar 28, 2009
Posts: 35
Is there a way to serialize an object to a specific location? I have a class (will post code) in a package that I "C:\>java" from the \classes directory, where the \com folder is, and it serializes the object in \classes, as opposed to the location of the actual class file.

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

If you use a relative path name in a FileOutputStream, then that path is relative to the current working directory. If you want it to go somewhere else, then use an absolute path. (This is simply a fact about path names, not about serialization per se.)

I don't think it's a good idea to put changeable data in the same directory where your classes are located, anyway. Perhaps you should put your data in the user's home directory, or a subdirectory of that which you create specifically for your application.
 
wood burning stoves
 
subject: Serialization location
 
Similar Threads
class invalid for deserialization
Can I pass character array to new method?
Threads and serialization
Why are transient static variables allowed?
basic concepts on Serialization