Results 1 to 9 of 9
- 09-01-2010, 12:10 PM #1
Member
- Join Date
- Sep 2010
- Posts
- 4
- Rep Power
- 0
update binary file from text file
i want to learn how i can update a dbs file from a text file,for example:
dbs.file
name1 tel1 e-mail1
name2 tel2 e-mail2
---------------------
text file
name1 tel1 e-mail3 e-mail4
name2 tel2 e-mail2 tel 1112222 phone 777777
-------------------------
update dbs
name1 tel1 e-mail1 e-mail3 e-mail4
name2 tel2 e-mail2 tel 1112222 phone 777777
can anyone help??????
- 09-01-2010, 12:23 PM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
What you mean by dbs file? In the title you are talking about binary file, but in the file you are talking about contain some text. Am I correct?
- 09-01-2010, 12:40 PM #3
Member
- Join Date
- Sep 2010
- Posts
- 4
- Rep Power
- 0
no it's no text,it's a binary file, it has records no characters!!!
- 09-01-2010, 01:54 PM #4
Check your terminology. Records can be built from characters.
A record is a sequence of bytes(could be chars) with some relationship.
Usually we use the term binary for data that can't be entered from the keyboard.
And text is what can be entered from a keyboard.
What is a "dbs" file? How does it relate to the text file? The examples you posted both appear to be files that contained text.
- 09-01-2010, 02:07 PM #5
Member
- Join Date
- Sep 2010
- Posts
- 4
- Rep Power
- 0
i think you haven't work a lot with files....of course i talk abou t bytestreams....and in a binary file there are records.writnig and reading is made with objects...serialization/desirialization....i don't understand where my terminology is wrong
- 09-01-2010, 02:41 PM #6
That's an interesting comment. Take a look at my profile.i think you haven't work a lot with files.
That does NOT mean that there are NOT records in other types of files. If you have a special meaning for the generic word record, please enclose it in quotes or add an adjective to show what specific type of record you are working with.in a binary file there are records
That's one way. There are others. What is an image file? It contains binary data and has nothing to do with objects and serialization.in a binary file ... writing and reading is made with objects
- 09-01-2010, 03:17 PM #7
Member
- Join Date
- Sep 2010
- Posts
- 4
- Rep Power
- 0
ok,i write an example how is the database:in the example i have already input some records,you give a record id and you can see the corresponding data.
the record members are:name-10 chars,tel(int),e-mail(10chars)
----------
RandomAccessFile infile=new RandomAccessFile(f,"rw");
long id,pos;
byte nam[]=new byte[20];
do
{System.out.println("record number (0:exit)==>");
id=object.console_long();
if (id==0) break;
pos=(id-1)*24;
infile.seek(pos);
for int j=0;j<10;j++)
nam[j]=infile.readByte();
tel=infile.readInt();
for (int i=0;i<10;i++)
System.out.println((char)nam[i]);
System.out.println(tel);
}
while(true);
infile.close();
)
)
my question is how i can update this file from a text file
- 09-01-2010, 03:33 PM #8
You have two files, one with binary records, the other with text records.how i can update this file from a text file
The "binary" file has records of length of 24 bytes with the following fields:
name - 10 bytes(char)
tel# - 4 bytes(int)
email - 10 bytes(char)
What is the layout of the records in the text file?
Your example showed that the changed binary file would have different length fields than the input file. If the email field is only 10 bytes long, how can you update it to be a longer field? Do the "fields" have delimiters or length fields to say how long they are?
And what about the "phone" data? That seems to be an new set of fields for the record.
- 09-02-2010, 09:24 AM #9
Moderator
- Join Date
- Apr 2009
- Posts
- 10,466
- Rep Power
- 16
Similar Threads
-
count character in text file as input file
By aNNuur in forum New To JavaReplies: 7Last Post: 03-25-2010, 04:01 PM -
Read file from directory, update contents of the each file
By svpriyan in forum New To JavaReplies: 2Last Post: 05-11-2009, 10:07 AM -
[SOLVED] how to reading binary file and writing txt file
By tOpach in forum New To JavaReplies: 3Last Post: 05-09-2009, 11:31 PM -
Converting a text file int binary
By sruthi_2009 in forum New To JavaReplies: 0Last Post: 03-23-2009, 03:09 PM -
Update Text File
By yuminstall in forum New To JavaReplies: 8Last Post: 01-09-2009, 03:02 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks