• 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

Error recording Ascii file with PrintWriter

 
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,

I have a program that has the following function:

- Receiving a string of 800 characters in Hex format, as below:

09dff751ac98c0925a2170de275a31c5462df93e08c1c086e7e277710a66408d01c38792c93819fbbd2bea9177896a2f2c15f7441353bfca30c1f4a97015294133f2e8cb7f4ebd2bfd79aebcb772305a6b1620a89e45344344064d55cff87adfaf026089f7fd3117176ce075cc00ef8279eee9cc782263be3ce4d3c5c88a68213941f4e2c3f6266450f0e0b87395d9677204edd52034c1feeaf2b4cb0d8b629f8dbd6310da4c0c532c1716485c898b4d08a9802947333df8e61195939d42a8605a86624c6db2a7a295417d9d5e6e320aeb7d97cb801ef4345fc745d9c651210c527e5731d1fb5ebff9091136ae338ca2845b2da7575590a496c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc28

- Convert this string to Ascii format.

- Record this string into one file "C:\\Nitgen\\biometria.rec".

The correct content of the recorded file should be as follows (the file is opened in the editor "Free Hex Editor Neo"):

.ß÷Q¬˜À’Z!pÞ'Z1ÅF-ù>ÁÀ†çâwq
f@Ç’É8û½+ê‘w‰j/,÷DS¿Ê0Áô©p)A3òèËN½+ýy®¼·r0Zk ¨žE4CDMUÏøz߯`‰÷ý1làuÌ


However, it is recording as a series of characters that is not being recognized, as follows:

.??Q???Z!p?'Z1?F-?>???wq
f@????8??+??w?j/,?DS??0???p)A3???N?+?y???r0Zk ??E4CDMU??z??`???1l?u?


Below the Java code:


What is wrong when the code records the file?

Thanks,

Fernando
 
Rancher
Posts: 1044
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Instead of the PrintWriter, you could use a FileOutputStream.
 
Ivan Jozsef Balazs
Rancher
Posts: 1044
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The output

.ß÷Q¬˜À’Z!pÞ'Z1ÅF-ù>ÁÀ†çâwq

does not look like containing ASCII characters. Something is not right with the requirement.
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have a program that has the following function:

- Receiving a string of 800 characters in Hex format, as below:

09dff751ac98c0925a2170de275a31c5462df93e08c1c086e7e277710a66408d01c38792c93819fbbd2bea9177896a2f2c15f7441353bfca30c1f4a97015294133f2e8cb7f4ebd2bfd79aebcb772305a6b1620a89e45344344064d55cff87adfaf026089f7fd3117176ce075cc00ef8279eee9cc782263be3ce4d3c5c88a68213941f4e2c3f6266450f0e0b87395d9677204edd52034c1feeaf2b4cb0d8b629f8dbd6310da4c0c532c1716485c898b4d08a9802947333df8e61195939d42a8605a86624c6db2a7a295417d9d5e6e320aeb7d97cb801ef4345fc745d9c651210c527e5731d1fb5ebff9091136ae338ca2845b2da7575590a496c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc2896c1e98b7dbbcc28




I don't know if this will solve your problem but there is an important difference between the beginning of the requirements string and the one in your code.
 
Marshal
Posts: 8880
638
Mac OS X VI Editor BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Fernando Skackauskas wrote:


And at some point, you possibly could suffer from exception related with index out of bounds.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic