Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

StringBuffer Problem or URLConnection ??  RSS feed

 
Harish Tam
Ranch Hand
Posts: 71
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

I would like some help with the reading of data using URLConnection class, here is my code to read the data


And then i use sbData.toString() to convert the data into String so that i cna use it for further processing, now the problem here is that the data that i read is encrypted for example i will give you the sample data


The above is the actual data that we have to read but what i read is the below, if you check there are some extra chars added while i read the data,




I am not sure how this is done can any body suggest any other method for reading such data using urlconnection. Thanks in advance!

Thanks and regards
Harish

JCE: disabled smilies and trimmed the examples - feel free to repost them if I took out something that's important
[ February 17, 2006: Message edited by: Joe Ess ]
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that binary data? Don't use a Reader.
Is that text? You will have to use a Reader with the same encoding to get the correct results.
 
Harish Tam
Ranch Hand
Posts: 71
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply, but i think i have solved the issue out here, byt using the following changes in the reading data



This have done the trick, while reading the data there are no extra chars added now, but there is still one more issue here, just wanted to know how java interrpret the euro symbol, here is the brief, what is done here is that the data is excrypted and this is simply done by adding 9 to each char this is done using a MSSQL database proc, and in java we read the data and convert it back to the original form, by taking each and every char and subtracting 9 from it, now the problem comes to chars which have their acsii value more then 127, i have check the value of 128 is different then what is interpreted by java, actually the 128 char represents euro, but in java it is different, and when we try to decrypt the data it is not decrypted correctly only for chars which are higher then 127......

So any body can suggest as to how can we maintain the same charset with java......

Regards
Harish
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!