| Author |
getBytes() urgent ????????
|
Gurpreet Saini
Ranch Hand
Joined: Jun 09, 2002
Posts: 295
|
|
Hi reader, I had fixed my deprecated String class constructor by using this following signature new String(byte[], int, int); But I am having a problem in using getBytes() method . Whenever, I book the seats on particular filght that record is skipped for ever. I do not understand why this happens ?. Please comply as soonas possible. Thank you, :roll:
|
 |
Ron Newman
Ranch Hand
Joined: Jun 06, 2002
Posts: 1056
|
|
|
Could you post some code that demonstrates the problem?
|
Ron Newman - SCJP 1.2 (100%, 7 August 2002)
|
 |
Michael Morris
Ranch Hand
Joined: Jan 30, 2002
Posts: 3451
|
|
Hi Gurpreet, I don't think it has to do with the readRecord at all. It probably has to do with how you built your DataInfo that was passed into the modify method on Data. Be sure that LIVE_RECORD is set on the DataInfo or the record will be skipped. Hope this helps, Michael Morris
|
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
|
 |
Gurpreet Saini
Ranch Hand
Joined: Jun 09, 2002
Posts: 295
|
|
Hi there, This is the code which skips the record on which modification of avalable seats is done: int size, space, toCopy; byte [] buffer = new byte[recordLen]; buffer[0] = LIVE_RECORD; int offset = 1; for (int i = 0; i < description.length; i++) { space = description[i].getLength(); // size = newData[i].length(); // toCopy = (size <= space) ? size : space; newData[i].getBytes(); offset += space; } db.write(buffer); }
|
 |
Michael Morris
Ranch Hand
Joined: Jan 30, 2002
Posts: 3451
|
|
Hi Gurpreet, You're not copying the bytes into buffer. You should have something like: Also, you should uncomment the "size = ..." and "toCopy = ..." lines. Hope this helps, Michael Morris
|
 |
Gurpreet Saini
Ranch Hand
Joined: Jun 09, 2002
Posts: 295
|
|
Hi Morris, I thank you, for your help. Now, it is functioning properly. Morris did your policy granted "all permissions" or it supplied certain parameters ?. Second, If I implement lock / unlock in Data class then does it mean that I am modifying Data class. This I am asking because my DataAccess class is extending Data class. Or shall I implement my lock / unlock in DataAccess class ?.
|
 |
Michael Morris
Ranch Hand
Joined: Jan 30, 2002
Posts: 3451
|
|
Hi Gurpreet,
Morris did your policy granted "all permissions" or it supplied certain parameters ?.
Yes.
Second, If I implement lock / unlock in Data class then does it mean that I am modifying Data class. This I am asking because my DataAccess class is extending Data class. Or shall I implement my lock / unlock in DataAccess class ?.
I would say no, but it would probably be better to implement them in the child class from a pure design point of view, otherwise why subclass Data in the first place? Hope this helps, Michael Morris
|
 |
 |
|
|
subject: getBytes() urgent ????????
|
|
|