473,406 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

ObjectOutputStream

63
I have this code to write to a file. However, this only saves one entry.
How can I save multiple entries, each saved in separate lines ?
At this point the output in the .txt file is strange:

’ t Peter|t Pan|t 01/09/67|t 098 1456789|t 18-Mar-2009|t Male Surgical Wardt 

I need the text to be clear in order to read it in a JTable


public void writeTable() {

try {

String ward = (String)wardCombo.getSelectedItem();

ObjectOutputStream file = new ObjectOutputStream
(new FileOutputStream("tablePat.txt"));

file.writeObject(name.getText() + "|");
file.writeObject(surname.getText() + "|");
file.writeObject(dobInput.getText() + "|");
file.writeObject(emgInput.getText() + "|");
file.writeObject(dateInput.getText() + "|");
file.writeObject(ward);
file.writeObject("\n");
file.close();

} catch (IOException ex) {

ex.printStackTrace();

}
}
Mar 18 '09 #1
1 3068
JosAH
11,448 Expert 8TB
An ObjectOutputStream doesn't write text; it writes a serialized version of objects instead. That serialized version can be read in again and a new object can be constructed out of that (non-text) data again by an ObjectInputStream. If you want text you're using the wrong stream for the purpose.

kind regards,

Jos
Mar 18 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Serial # 19781010 | last post by:
I have a multithreaded server - one thread / client. I have a client 1 connected to thread A, and a I have client 2 connected to thread B. After certain equal period of inactivity Client 1 sends a...
6
by: Kiran Kumar Kamineni | last post by:
Do I have to implement the serializable interface? Is the default implementation of the serializable interface enough?
0
by: Ray Mitchell | last post by:
Hello, The result of auto-converting some Java code to C# yielded the following upgrade issue regarding the original Java call to "reset()": public virtual void writeObj(Object obj) {...
1
by: Kannan T via .NET 247 | last post by:
Hi All, Is there any equivalent C# method for reset method of ObjectOutputStream in Java If so do let me know. Advance Thanks ! ! ! -------------------------------- From: Kannan T ...
1
by: rengaraj | last post by:
JBoss version:4.0.4 Hibernate version:3.2 Database:Oracle10g Hi. I am facing an entity mapping problem. I have an Oracle stored function which takes as a parameter an Oracle array and returns a...
6
by: khajeddin | last post by:
hi: i have a program which should read and werite on a file but after the first time it writeon the file it can read te records.but other times it write on the file but just read the records which...
1
by: amgupta8 | last post by:
Note: This problem occurred when I updated the JDK from 1.3.1 to 1.4.1 or 1.4.2. Nothing else was changed in the code, other than updating the JDK on the database server (dbm cfg parm jdk_path) and...
0
by: kuguy | last post by:
Hi all, I'm new to the forums, so I hope this isn't in the wrong place... I have that "Software caused connection abort: socket write error" exception error that i've never meet before. ...
13
by: milk242 | last post by:
I know I'm making a mistake, but I'm wondering if someone could tell me the type of mistake I'm making. I know I can write the whole array to a file, but I want to create separate binary files for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.