serialization

sending serialization file via sockets in java

核能气质少年 提交于 2020-01-05 08:14:23
问题 System.out.println("Java is awesome!"); Pardon my enthusiasm; I just can't believe how powerful Java is, what with its ability to not only save objects (and load them), but also with its main purpose, to send them over a network. This is exactly what I must do, for I am conducting a beta-test. In this beta-test, I have given the testers a version of the game that saves the data as Objects in a location most people don't know about (we are the enlightened ones hahaha). This would work fine and

With out implementing a Serializable interface is it possible to make a class persistable in java?

末鹿安然 提交于 2020-01-05 07:36:29
问题 In Java we implement an interface Serializable that defines no method (also called a marker interface). But suppose I have an interface without any method just like a Serializable interface, can I make it work just like that, meaning that I would be able to use my interface instead of the Serializable ? Thanks 回答1: Only Serializable will mark an object as being compatible with Java's built-in serialization machinery. You can create other empty interfaces, but they won't mean the same thing.

protobuf-net deserialize base class to inherited class

≯℡__Kan透↙ 提交于 2020-01-05 07:21:20
问题 I have base class which is serialized. [ProtoContract] public class Web2PdfEntity { [ProtoMember(1)] public string Title { get; set; } [ProtoMember(2)] public string CUrl { get; set; } } I would like to deserialize Web2PdfEntity class to Web2PdfServer which is inherited from Web2PdfEntity. public class Web2PdfServer : Web2PdfEntity { public void MyServerMethod {} public void MyServerMethod2{} } I have tried to use code below to deserialize class, unfortunately the properties are not set. var

Serializing fields in a custom DataSet to XML

坚强是说给别人听的谎言 提交于 2020-01-05 06:52:07
问题 Is there any way to add fields to a DataSet which will be serialized along with the table information when the DataSet is serialized in XML? I have some information that describes the DataSet that I want to try to include inside it when I throw it around in XML. I've tried adding fields and classes in the partial class Visual Studio generates for you for validation methods but I can't seem to get them to show up alongside the table information in the XML file either when myDataSet.WriteXML()

Javafx IO Exception about “implements Serializable”

蹲街弑〆低调 提交于 2020-01-05 06:04:54
问题 I have some trouble on javafx FILE IO. I have implemented Serializable but there is also some wrong. Thank you for your help. 1.Appdata class package data; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import javafx.beans.property.SimpleStringProperty; import javafx.collections.FXCollections; import javafx

Shove failing because of pretty basic ld vs. optimize issue in stuf.util

纵饮孤独 提交于 2020-01-05 05:56:39
问题 I ran against another issue with shove (see Shove knowing about an object but unable to retrieve it ), but this time I've got a pretty simple repro showing why the dump/load doesn't work. Looking at the def in C:\Python27\lib\site-packages\shove-0.5.0-py2.7.egg\shove\base.py for loads/dumps, it refers to ld,optimize in stuf.utils. How come the below does not work? >>> from stuf.utils import ld,optimize; d=[{'A':1},{'A':1}]; ld(optimize(d)) [{'A': 1}, {'A': 1}] >>> from stuf.utils import ld

Using Microsoft.FSharpLu to serialize JSON to a stream

无人久伴 提交于 2020-01-05 05:48:14
问题 I've been using the Newtonsoft.Json and Newtonsoft.Json.Fsharp libraries to create a new JSON serializer and stream to a file. I like the ability to stream to a file because I'm handling large files and, prior to streaming, often ran into memory issues. I stream with a simple fx: open Newtonsoft.Json open Newtonsoft.Json.FSharp open System.IO let writeToJson (path: string) (obj: 'a) : unit = let serialized = JsonConvert.SerializeObject(obj) let fileStream = new StreamWriter(path) let

Silverlight 3.0 Binary Serialization Support?

柔情痞子 提交于 2020-01-05 05:25:40
问题 Can I deserialize an object in the Silverlight 3.0 runtime that was serialized using the full .NET 2.0 runtime using the BinaryFormatter? I am using the following code to serialize an object to a ByteArray which we write to a DB table: MemoryStream serStream = new MemoryStream(); BinaryFormatter binFormatter = new BinaryFormatter(); binFormatter.Serialize(serStream, csMetric); serStream.Position = 0; return serStream.ToArray(); The Silverlight client then needs to retrieve this binary data

Silverlight 3.0 Binary Serialization Support?

泄露秘密 提交于 2020-01-05 05:25:15
问题 Can I deserialize an object in the Silverlight 3.0 runtime that was serialized using the full .NET 2.0 runtime using the BinaryFormatter? I am using the following code to serialize an object to a ByteArray which we write to a DB table: MemoryStream serStream = new MemoryStream(); BinaryFormatter binFormatter = new BinaryFormatter(); binFormatter.Serialize(serStream, csMetric); serStream.Position = 0; return serStream.ToArray(); The Silverlight client then needs to retrieve this binary data

SecurityException when serializing with DataContractSerializer

柔情痞子 提交于 2020-01-05 04:58:26
问题 I'm trying to serialize the state of my game on Windows Phone 7, and so made a "Save" struct so I could easily convert all the states into an XML doc using DataContractSerializer. The Save() code worked fine when I just serialized each data member of the Gamestate individually. However this led to a multiple xml root error, so I made the "Save" class to act as the sole root. Now I get a security exception whenever I try and call DataContractSerializer.WriteObject() on anything. I've been