473,387 Members | 1,579 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,387 software developers and data experts.

Random Access Saving

63
I'm trying to save fixed length data into a random access file. Right now it works,
but saves everything in one, continuous line. How can save every new entry in
a new line. Also, I want to separate fields with a "|" character in order to read the file into a JTable.

i.e:

Id|Name|City|Phone
102|Beth Reiser|New York|(212)5558725
111|Dylan Ricci|Syracuse|(315)5554486
116|Brian Gugliuzza|Mamaroneck|(914)5553817
120|Gertrude Stein|Elmsford|(914)5553476
131|Daljit Sinnot|Bohemia|(516)5559811


Expand|Select|Wrap|Line Numbers
  1. public void writeDetails() {
  2.  
  3.         try {
  4.  
  5.             patient a = new patient();
  6.  
  7.             a.patName = name.getText();
  8.                        a.patSurname = surname.getText();
  9.                        a.patDob = dobInput.getText();
  10.             a.patAddress = addInput.getText();
  11.             a.patEmgNum = emgInput.getText();
  12.             a.patCheckInDate = dateInput.getText();
  13.             a.patCheckInTime = timeInput.getText();
  14.             a.patWard = (String)wardCombo.getSelectedItem();
  15.             a.patDoctor = (String)doctorCombo.getSelectedItem();
  16.  
  17. raf.seek(raf.length());
  18. FixedLengthStringIO.writeFixedLengthString(a.patName, NAME_SIZE, raf);
  19. FixedLengthStringIO.writeFixedLengthString(a.patSurname, SURNAME_SIZE, raf);
  20. FixedLengthStringIO.writeFixedLengthString(a.patDob, DOB_SIZE, raf);
  21. FixedLengthStringIO.writeFixedLengthString(a.patAddress, ADD_SIZE, raf);
  22. FixedLengthStringIO.writeFixedLengthString(a.patEmgNum, EMG_SIZE, raf);
  23. FixedLengthStringIO.writeFixedLengthString(a.patCheckInDate, DATE_SIZE, raf);
  24. FixedLengthStringIO.writeFixedLengthString(a.patCheckInTime, TIME_SIZE, raf);
  25. FixedLengthStringIO.writeFixedLengthString(a.patWard, 20, raf);
  26. FixedLengthStringIO.writeFixedLengthString(a.patDoctor, 30, raf);
  27.  
  28. JOptionPane.showMessageDialog(null, "PATIENT DETAILS SAVED", "INFORMATION", JOptionPane.INFORMATION_MESSAGE);
  29.  
  30. } catch (IOException ex) {
  31.  
  32.     ex.printStackTrace();
  33.  
  34.       }
  35. }
Mar 18 '09 #1
1 2043
RedSon
5,000 Expert 4TB
Please use code tags around your code snippits.

Why don't you just add a new line between every entry? "\n"
Mar 18 '09 #2

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

Similar topics

26
by: Chris Lasher | last post by:
Hello, I have a rather large (100+ MB) FASTA file from which I need to access records in a random order. The FASTA format is a standard format for storing molecular biological sequences. Each...
11
by: Dr John Stockton | last post by:
Q1 : Given an array such as might have been generated by var A = is there a highly effective way of reducing it to - i.e. removing the undefineds and shifting the rest down? ...
3
by: Tlaker | last post by:
MS Works 6.0 to Access 2000. Tried saving to *.csv and dbf as well as converting to Excel then loading but to no avail. My Works database has about 4000 records, each with about 30 fields. Is...
4
by: tshad | last post by:
I am trying to set up an Image authorization where you type in the value that is in a picture to log on to our site. I found a program that is supposed to do it, but it doesn't seem to work. ...
3
by: Kza | last post by:
Hi, I am currently using xerces sax parser for c++, (I use DOM too, but I think SAX is more relevant here) for processing and displaying fairly large xml files. Usually I give xerces a filename,...
26
by: Jimmy | last post by:
ill have a database with 1 table and 3 fields: ID FIRSTNAME LASTNAME (the ID field will be the auto incrementing index) there might be 10 records in the DB, there might be 10,000. i...
11
by: Kevin Williamson | last post by:
Hi, I've written a lottery programme in PHP that selects 10 winners a week from approximately 18,000 shares. The problem I have is that of the ten winners one week the same share number was...
4
by: castironpi | last post by:
I'd like to seriously nominate this idea and get a considered opinion on it. struct.Struct lets you encode Python objects into structured memory. It accepts a format string, and optionally a...
1
by: MiziaQ | last post by:
I'm trying to save fixed length data into a random access file. Right now it works, but saves everything in one, continuous line. How can save every new entry in a new line. Also, I want to separate...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.