Skip to content

Tag: java

How to remove the last character from a string?

I want to remove the last character from a string. I’ve tried doing this: Getting the length of the string – 1 and replacing the last letter with nothing (deleting it), but every time I run the program, it deletes middle letters that are the same as the last letter. For example, the word is &#8220…

How to Convert Int to Unsigned Byte and Back

I need to convert a number into an unsigned byte. The number is always less than or equal to 255, and so it will fit in one byte. I also need to convert that byte back into that number. How would I do that in Java? I’ve tried several ways and none work. Here’s what I’m trying to do now:

PKCS#12 : DerInputStream.getLength() exception

I generate a certificate using the keytool command: Then if I try to load it using java security API, after getting the file as a byte[] : I get a DerInputStream.getLength(): lengthTag=127, too big exception. What is wrong? Answer I had this problem and I’ve searched the depths of google and still could…

Nested functions in Java

Are there any extensions for the Java programming language that make it possible to create nested functions? There are many situations where I need to create methods that are only used once in the context of another method or for-loop. I’ve been unable to accomplish this in Java so far, even though it c…