Thanks Ben - that's really useful to know! 

I'll give that a try tomorrow.

Sent from my iPad

On 7 Jan 2013, at 22:54, Benjamin Browning <bbrown...@redhat.com> wrote:

> There is a way to get an InputStream from a file in JRuby without using 
> FileInputStream:
> 
> File.new("example.jks").to_inputstream
> 
> So your example becomes:
> 
> kstore.load(File.new("example.jks").to_inputstream, 
> "lexicon".to_java.toCharArray)
> 
> Ben
> 
> On Jan 7, 2013, at 5:32 PM, Carl Bourne <carl.bou...@me.com> wrote:
> 
>> Thanks Ben, 
>> 
>> That did the trick perfectly! 
>> 
>> On another note, is there an easier way to load the example.jks keystore 
>> file without needing to use Java's FileInputStream? 
>> 
>> Regards,
>> 
>> Carl Bourne
>> 
>> On 7 Jan 2013, at 22:10, Benjamin Browning <bbrown...@redhat.com> wrote:
>> 
>>> You can accomplish the same thing without String.new via
>>> 
>>> "lexicon".to_java.toCharArray
>>> 
>>> And, I wouldn't suggest using java_import for java.lang.String since as 
>>> you've noticed (via the already initialized constant warning) that 
>>> conflicts with Ruby's built-in String class.
>>> 
>>> Ben
>>> 
>>> On Jan 7, 2013, at 5:03 PM, Carl Bourne <carl.bou...@me.com> wrote:
>>> 
>>>> Hi,
>>>> 
>>>> I may be misunderstanding something here, but Is there an easy way in 
>>>> JRuby/Ruby to convert a string such as "lexicon" into a character array? 
>>>> 
>>>> The only way I've been able to achieve this so far is like this: - 
>>>> 
>>>>> String.new("lexicon").toCharArray)
>>>> 
>>>> 
>>>> Which requires me to: - 
>>>> 
>>>>> java_import java.lang.String
>>>> 
>>>> 
>>>> Which then creates warnings like this when I run my code: -
>>>> 
>>>>> warning: already initialized constant String
>>>> 
>>>> 
>>>> I was assuming there would a more Ruby like way to achieve this without 
>>>> having to use java.lang.String. 
>>>> 
>>>> My objective is to open a Java Keystore file which requires a password. 
>>>> e.g.
>>>> 
>>>> kstore.load(FileInputStream.new("example.jks"), 
>>>> String.new("lexicon").toCharArray)
>>>> 
>>>> Best Regards,
>>>> 
>>>> Carl
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe from this list, please visit:
>>>> 
>>>> http://xircles.codehaus.org/manage_email
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe from this list, please visit:
>>> 
>>>  http://xircles.codehaus.org/manage_email
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe from this list, please visit:
>> 
>>   http://xircles.codehaus.org/manage_email
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
> 
>    http://xircles.codehaus.org/manage_email
> 
> 

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to