Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Remove spaces from byte array

843785Oct 18 2008 — edited Oct 19 2008
Hi All.

I've got an array of bytes (ASCII)
I need to work backwards and remove any spaces from this byte array.
I've tried looping backwards using a for loop, this never gets entered.
I've tried dumping into an arraylist and iterating backwards like so
ArrayList<Byte> listRemove = new ArrayList<Byte>();
for (int i = 0 ; i < bytResponse.length; i++){
	listRemove.add(bytResponse);
}
ListIterator<Byte> listItByte = listRemove.listIterator();
while (listItByte.hasPrevious()) {
System.out.println(boo);
}
However, even that does not get entered into(the while loop). 

The reason I'm doing is because I have a byte array and I wish to remove any spaces but starting from the back.  
I'm running out of ideas on how I can remove my spaces!  I know the ASCII code for space is 32, but without a means of even looping through the array, I can't even start on how I can do any comparisons without throwing any dereferencing errors.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 16 2008
Added on Oct 18 2008
3 comments
1,230 views