• Post Reply Bookmark Topic Watch Topic
  • New Topic

Error java.util.UnknownFormatConversionException  RSS feed

 
Fernando Skackauskas
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

I have the following code which the function is convert a Hex String to Ascii format and write to a file.

The String in Hex is "dado".



But the problem is that, most of the time the program runs correctly, but sometimes gives the following error message, depending of the Hex String;

Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = ''
at java.util.Formatter.checkText(Formatter.java:2547)
at java.util.Formatter.parse(Formatter.java:2533)
at java.util.Formatter.format(Formatter.java:2469)
at java.io.PrintWriter.format(PrintWriter.java:905)
at java.io.PrintWriter.printf(PrintWriter.java:804)
at listening.Listening.main(Listening.java:260)


The error occurs at the command:




What should be changed in the program so it does not give this error?

Thanks,

Fernando
 
Tony Docherty
Bartender
Posts: 3209
78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using printf() rather than print()?
printf assumes that what is passed in is a format string which isn't the case. I suspect every so often one of the values in the input string is an illegal format sequence and hence the exception.
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fernando Skackauskas wrote:. . . The String in Hex is "dado". . . .
Maybe you mean dad0 because dado is not a valid hex number.
 
Tony Docherty
Bartender
Posts: 3209
78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:
Fernando Skackauskas wrote:. . . The String in Hex is "dado". . . .
Maybe you mean dad0 because dado is not a valid hex number.

I thought the OP meant the hex string is in 'dado' as that is the name of the variable.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!