Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Value changes from "1" to "l" after reading to file  RSS feed

 
David Goekel
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a very confusing situation. In my program, I write an Array to file, then manipulate parts of the array and write it to file again.

However, in between some of the identifiers, stored as String, with value turn into an sometime after writing them to file the first time. Again, this field is a String identifier...it is not supposed to change. What's more, the value saved in Java memory has changed, I tried to cast it to an int when writing to file, thinking that it was the write process where the error happened. This resulted in parseInt errors. The strangest thing is that only some of them change, and it seems to be the same ones each time that change.

Even though right now this identifier is all integers, it usually is not, so No, I cannot just save it as an int to begin with.

Thank you for any insight,
David
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Writing an Array to a file ? I'm curious to see how you write it.

in between some of the identifiers, stored as String, with value

In between ? When exactly ?
 
David Goekel
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure. So myarray is an array of objects, myobject. I write to file using the method



And then that toString() is a method of myobject:


 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where are you looking at when you see it changing ? A debugger ? A log ?
 
David Goekel
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have made a huge mistake. Nothing is wrong. Please delete this thread if you can. My apologies.

(the identifier printed to the first file was a different identifier, but was also always 1...the mysterious identifier was formed by taking the last character from an SQL query and some of the identifiers were null).
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We all do mistakes. The important thing is that your problem is solved.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!