Results 1 to 4 of 4
- 03-13-2012, 07:14 AM #1
Member
- Join Date
- Dec 2011
- Posts
- 57
- Rep Power
- 0
Removing thr last two bytes from string
Hi
I want to split a string in two. I want the last two bytes to be in one string and the rest in an other. The problem is I don't know the length of the string.
Im collecting data from a serial inputstream and the last two bytes are CRC. I need to control that crc is correct befor I handle the data in the stream.
Will some thing like this work :
Or am I far off?Java Code:input.getLength(i); input.split(i - 2);
- 03-13-2012, 08:30 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,406
- Blog Entries
- 7
- Rep Power
- 17
- 03-13-2012, 08:47 AM #3
Member
- Join Date
- Dec 2011
- Posts
- 57
- Rep Power
- 0
Re: Removing thr last two bytes from string
Thanks for fast answer Jos
The shortest the string can be is 15 bytes. The crc is on 6 bytes in the message.
- 03-13-2012, 09:29 AM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,406
- Blog Entries
- 7
- Rep Power
- 17
Re: Removing thr last two bytes from string
When people rob a bank they get a penalty; when banks rob people they get a bonus.
Similar Threads
-
Removing All Commas from a String
By andy9507 in forum New To JavaReplies: 6Last Post: 05-12-2011, 04:16 AM -
Removing words from a String
By nn12 in forum New To JavaReplies: 3Last Post: 03-15-2011, 10:50 AM -
Removing last character from a String
By newToJava3 in forum New To JavaReplies: 2Last Post: 11-28-2010, 12:43 AM -
Converting the bytes recieved from the web-server into string...
By adil_fastian in forum NetworkingReplies: 1Last Post: 04-10-2010, 04:37 PM -
Removing all the instances of a given text form a String
By Java Tip in forum Java TipReplies: 1Last Post: 01-11-2008, 10:06 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks