This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

modify method in Data Class

 
raphael Bereh
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
In the FBN assignment I am trying to use the method public synchronized void modify(DataInfo newData) in the Data Class but it does not write the data as expected. The record writen is blank
Has Anyone used the method successfully ?
Thanks
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you checked the DataInfo class that you are passing in to the modify method. Check to see that is has values in it. Put System.outs in the modify method that will print the values of the DataInfo class that you pass.
Also did you change the deprecated method in the writeRecord method? This could also be important how you fixed it. I remember having a problem saving too, and I found that my solution to the deprecated method wasn't quite right.
Mark
 
ravindra janapreddy
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the similar problem after invoking the modify method a blank record is being written to the db file. I have printed out the DataInfo object using System.out.println and it has all the values.
Please resolve the issue.
Thanks
Ravi
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like it has something to do with deprecated line in writeRecord() method.
 
ravindra janapreddy
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sai
This is my fix for the deprecated line. Is it wrong ?
for (int i = 0; i < description.length; i++) {
space = description[i].getLength();
size = newData[i].length();
toCopy = (size <= space) ? size : space;
//newData[i].getBytes(0, toCopy, buffer, offset);
String enc = "ISO-8859-1";
newData[i].getBytes( enc );
offset += space;
}
Thanks
Ravi
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. You are missing two steps.
You need to figure out how much of newData[i] is to be converted to byte[].
Also you need to populate/copy the buffer[] with the above value.
Default encoding should be fine.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic