• 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

javac thinks byte[] is a String

 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found this thread:

https://coderanch.com/t/374496/java/java/send-byte-array

here, so I figure this is the approriate forum.

I am using the org.apache.xerces.impl.dv.util.Base64. More precisely, I am trying to use it. I have tried all the combinations I can imagine to get my digest bytes into it, finally resorting to simply creating a new byte[] as a test.

This is what javac thinks of my test:

Any ideas what is going on here? I know that I don't find a String where byte[] is required in that code.

I'm compiling with JDK 1.4.2_06 on XP.

I'm limited in my choices for a Base64 encoder, due to an arduous process for getting third party code approved for deployment. I may just write one myself, but I'd still like to know why I get this compilation error.

Thanks,

Joe
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[Joe]: I know that I don't find a String where byte[] is required in that code.

And yet, it's there.

    byte[] h = Base64.encode(new byte[5]);

The left hand side is saying it expects a byte[]:

    byte[] h =

On the right hand side, this part here is indeed a byte[]:

    new byte[5]

But when you call the encode() method, it returns a String.

    Base64.encode(new byte[5]);

Thus, you probably want code that looks something like this:

    String s = Base64.encode(new byte[5]);
[ July 11, 2006: Message edited by: Jim Yingst ]
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error message is telling you that the method returns a String, not a byte[]. Base64 encoding turns bytes into text.
 
Joe Gilvary
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Duh!

Thanks,

Joe
 
reply
    Bookmark Topic Watch Topic
  • New Topic