PIPE separated format is one of the formats used while sending data to and from mainframes. Client applications interacting with mainframes may be required to create requests and parse responses in this format.
This code snipped could be used to parse the input given as a PIPE separated string. It takes two inputs. One is the pipe separated string and other is the position. Content of the input string present in that position is given as output.
This code snipped could be used to parse the input given as a PIPE separated string. It takes two inputs. One is the pipe separated string and other is the position. Content of the input string present in that position is given as output.
private static final String getString(String buffer, int pos) { int i,tCharCount=0; boolean isStarted = false; int start=0, end=0; char tChar = 166; for(i=0;i<buffer.length();i++) { if(tCharCount == pos-1) { if(!isStarted) { start = i; isStarted = true; } } if(buffer.charAt(i) == tChar) { if(isStarted) { end = i; break; } else tCharCount++; } } return buffer.substring(start,end); }