• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

getBytes() urgent ????????

 
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
 
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you post some code that demonstrates the problem?
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Gurpreet Saini
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 295
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic