الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

Q: How To Deserialize A Hashtable

مغلق
بدأه Eng_Maythem في 30 أغسطس 2007 · 4 رد · 1,887 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

Al-Salam 3alaikom,

Good day,

Sorry for writting in English, actually i'm An Arabic Eng. but studying in London currently, and they don't have Arabic System on their computers.

Please i'd like to ask question, i had a problem when i serialize a hashtable then deserialize it, when i deserialize it into a hashtable, it appears like a one item only.

For example, if i created a hashtable with 10 entries, then serialize it. ... after some time, i came and deserialize it into a hashtable, when i retrive the contents of the hashtable i find it has one entry inside it, and this entry has all the ten entries combined togather.

so my question is, how can i Serialize the Hashtable and deserialize it and get the same Hashtable exactly?

could you please provide me with the code?

Jazakom Allah Khair..... & Have a nice day.

Al-Salam 3alaikom Wa Ra7mato Allah Wa Barakatooh.

Your Brother Maythem :)

#2

في الحقيقة لا اعرف ماذا تقصد بـ deserialization

لو تضع كود المشكلة يمكن يكون افضل

منقطع من حين لاخر

#3

Deserialization هو العمليه العكسيه للـ Serialization

مادام انك تستعمل هاش تيبل فهو Serialize بالأصل

لذلك لاتحتاج سوى أن تضع المعلومات بعدها تكتب writeObject(hashtable)

وفي الDeserialize

(hashtable) readObject

ان استمرت المشكله ارفق الكود

#4

AL-SALAM 3ALAIKOM,

Sorry for writting in English. and sorry for the late reply.

FOR( My brother ESSA ):

i'll try this one and Allah Kareem.

Thank you So Much and JAZAK Allah KHAIR AL-JAZAA'.

FOR (My Brother ABO FU'AAD):

Thank you for trying to help me, and this is the meaning of both Serializing & Deserializing;

SERIALIZATION: is the operation of SAVING an Object's features (into a file) to be used in another time.

DE-SERIALIZATION: is the Operation of LOADING The features of a serialized Object (From a file), into an object of the same class.

your Brother Maythem

#5

السلام عليكم

هذا كود على السريع يشرح ماقلته بالسابق

public class Main {

static void Serialize() throws Exception{
	Hashtable h=new Hashtable();
	h.put("1", "arab");
	h.put("2", "team");
   FileOutputStream fos=new FileOutputStream(new File("aa.txt"));
   ObjectOutputStream oos=new ObjectOutputStream(fos);
   oos.writeObject(h);
}
static void Deserialize() throws Exception{
	 Hashtable h=null;
	FileInputStream fis=new FileInputStream(new File("aa"));
	ObjectInputStream ois=new ObjectInputStream(fis);
  h=(Hashtable) ois.readObject();
	 System.out.println(h.get("1"));
	 System.out.println(h.get("2"));
}
		public static void main (String [] args) throws Exception{
		Serialize();
		Deserialize();


		}

}

هذا الموضوع مغلق.

مواضيع مشابهة