File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Printing two substrings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Printing two substrings" Watch "Printing two substrings" New topic
Author

Printing two substrings

Dean WinchesterD
Greenhorn

Joined: May 06, 2011
Posts: 13
Hey guys

I'm having this annoying problem with the substring method.

I use DataInputReader to read a raw binary file into a byte array.

Then I create a string from the array with: new String(myArray).

Now comes the weird part.

I cut two values from the String, lets say:



Then I add both string to an object:


And this object has an toString method where something goes wrong:



This method only prints the value of 'a' and ignores 'b'... But it works fine when I just return 'a' or 'b', so 'b' does have a value.

What could be the problem?

Regards
Dean
Udara Amarasinghe
Ranch Hand

Joined: Aug 17, 2009
Posts: 109

Hi dean,

Is it return correct value when you run this code
Dean WinchesterD
Greenhorn

Joined: May 06, 2011
Posts: 13
Yes, they both print when tested separately.
Udara Amarasinghe
Ranch Hand

Joined: Aug 17, 2009
Posts: 109

Can you post your storing objects whole source code?
Dean WinchesterD
Greenhorn

Joined: May 06, 2011
Posts: 13


The object is created here:



Udara Amarasinghe
Ranch Hand

Joined: Aug 17, 2009
Posts: 109

Dean you have made a mistake in create methods line 31.

try these codes. compile and run.


I didn't made any change to AudioObjects code.
Dean WinchesterD
Greenhorn

Joined: May 06, 2011
Posts: 13
Alright, thank you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Printing two substrings