I have a problem when comparing Strings. Let's say for example I have a buffer for a string that holds 1024 bits. If I fill that buffer up with the String "Hello", then the buffer would contain "Hello" + the remaining amount of bytes. If I create another String assigned "Hello", without any pre-assigned buffer. The two would never be equal because of this buffer.
byte buffer = new byte; String a = someInputStream.read(buffer); // A will contain "Hello" + rest of bytes. String b = "Hello"; // Same string but with no buffer System.out.println(a.equals(b)); // Would print false
Is there any way that I could compare these two strings without considering the buffer?