Prepare for your Next Interview
This is a discussion on Problems faced in execution within the Java forums, part of the Software Development category; import java.util.StringTokenizer; import java.util.ArrayList; public class Test { public static final String COMMA_DELIMITER = ","; String aLineA = "a= abcd"; // inline:/+c8nARgUo0DJyPkMoBm6hGRMYpCFZUGKYY61+qM"; String vLineA = &...
|
|||
|
Problems faced in execution
import java.util.StringTokenizer;
import java.util.ArrayList; public class Test { public static final String COMMA_DELIMITER = ","; String aLineA = "a= abcd"; // inline:/+c8nARgUo0DJyPkMoBm6hGRMYpCFZUGKYY61+qM"; String vLineA = "a= ijkl"; // inline:llhG/8JE//+o/8I9/+h1//+DOxsneRJpFnNb/41z"; // Initialize Audio and Video Cry Variables for Format "AES_CM_128_HMAC_SHA1_32" String aLineB = "a= efgh"; // inline:/+c8nARgUo0DJyPkMoBm6hGRMYpCFZUGKYY61+qM"; String vLineB = "a= mnop"; // inline:llhG/8JE//+o/8I9/+h1//+DOxsneRJpFnNb/41z"; int token = 0; String Life = "24,25,28"; String Length = "4"; StringBuffer aCryA = new StringBuffer(); StringBuffer aCryB = new StringBuffer(); StringBuffer vCryA = new StringBuffer(); StringBuffer vCryB = new StringBuffer(); public Test() { printValues(); } public void printValues() { getAudA(); getVidA(); } public String getAudA() { String value = null; int c = 1, j=1; aCryA.append(aLineA); aCryB.append(aLineB); if ((Life != null) && (Length != null)) { StringTokenizer stk = new StringTokenizer(Life, ","); token = stk.countTokens(); while (stk.hasMoreTokens()) { String s = stk.nextToken(); aCryA.append("inline"); aCryA.append("|"); aCryA.append(s); aCryA.append("|"); aCryA.append(c++ + ":" + Length); aCryB.append("inline"); aCryB.append("|"); aCryB.append(s); aCryB.append("|"); aCryB.append((j + token++) + ":" + Length); if (c <= token) { aCryA.append(";"); aCryB.append(";"); } } System.out.println(aCryA); System.out.println(aCryB); } return value; } public String getVidA() { String value = null; int c = 2, j=2; vCryA.append(vLineA); vCryB.append(vLineB); if((Life != null) && (Length != null)) { StringTokenizer stk = new StringTokenizer(Life, ","); token = stk.countTokens(); while (stk.hasMoreTokens()) { String s = stk.nextToken(); vCryA.append("inline"); vCryA.append("|"); vCryA.append(s); vCryA.append("|"); vCryA.append((c+2 + token++) + ":" + Length); vCryB.append("inline"); vCryB.append("|"); vCryB.append(s); vCryB.append("|"); vCryB.append((j++ + token++) + ":" + Length); if (c <= token) { vCryA.append(";"); vCryB.append(";"); } } System.out.println(vCryA); System.out.println(vCryB); } return value; } public static void main(String[] args) { new Test(); } } output : a= abcdinline|24|1:4;inline|25|2:4;inline|28|3:4; a= efghinline|24|4:4;inline|25|5:4;inline|28|6:4; a= ijklinline|24|7:4;inline|25|9:4;inline|28|11:4; a= mnopinline|24|6:4;inline|25|9:4;inline|28|12:4; i want output sequentially as: (The output depends on "Life" value) a= abcdinline|24|1:4;inline|25|2:4;inline|28|3:4; a= efghinline|24|4:4;inline|25|5:4;inline|28|6:4; a= ijklinline|24|7:4;inline|25|8:4;inline|28|9:4; a= mnopinline|24|10:4;inline|25|11:4;inline|28|12:4; (The output depends on "Life" value) for e.g if you giv Life= "25,26" then output as a= abcdinline|24|1:4;inline|25|2:4 a= efghinline|24|3:4;inline|25|4:4 a= ijklinline|24|5:4;inline|25|6:4 a= mnopinline|24|7:4;inline|25|8:4 (Note ";" will not come at the end) please give me solution ASAP. Regards jeya |
| Sponsored Links |
|
|||
|
Re: Problems faced in execution
i solved this. if any problem reply
import java.util.StringTokenizer; import java.util.ArrayList; public class test{ public static final String COMMA_DELIMITER = ","; String aLineA = "a= abcd"; // inline:/+c8nARgUo0DJyPkMoBm6hGRMYpCFZUGKYY61+qM"; String vLineA = "b= ijkl"; // inline:llhG/8JE//+o/8I9/+h1//+DOxsneRJpFnNb/41z"; // Initialize Audio and Video Cry Variables for Format "AES_CM_128_HMAC_SHA1_32" String aLineB = "c= efgh"; // inline:/+c8nARgUo0DJyPkMoBm6hGRMYpCFZUGKYY61+qM"; String vLineB = "d= mnop"; // inline:llhG/8JE//+o/8I9/+h1//+DOxsneRJpFnNb/41z"; int token = 0; String Life = "24,25,28"; String Length = "4"; StringBuffer aCryA = new StringBuffer(); StringBuffer aCryB = new StringBuffer(); StringBuffer vCryA = new StringBuffer(); StringBuffer vCryB = new StringBuffer(); public test() { printValues(); } public void printValues(){ getAudA(); getVidA(); } public String getAudA() { String value = null; int c = 1, j=1; aCryA.append(aLineA); aCryB.append(aLineB); if ((Life != null) && (Length != null)) { StringTokenizer stk = new StringTokenizer(Life, ","); token = stk.countTokens(); int tst = stk.countTokens(); while (stk.hasMoreTokens()) { String s = stk.nextToken(); aCryA.append("inline"); aCryA.append("|"); aCryA.append(s); aCryA.append("|"); aCryA.append(c++ + ":" + Length); aCryB.append("inline"); aCryB.append("|"); aCryB.append(s); aCryB.append("|"); aCryB.append((j + token++) + ":" + Length); tst--; if (c <= token) { if(tst > 0 ){ aCryA.append(";"); aCryB.append(";"); } } } System.out.println(aCryA); System.out.println(aCryB); } return value; } public String getVidA() { String value = null; int c = 2, j=2; vCryA.append(vLineA); vCryB.append(vLineB); if((Life != null) && (Length != null)) { StringTokenizer stk = new StringTokenizer(Life, ","); token = stk.countTokens(); int tst = stk.countTokens(); while (stk.hasMoreTokens()) { String s = stk.nextToken(); vCryA.append("inline"); vCryA.append("|"); vCryA.append(s); vCryA.append("|"); vCryA.append((c+2 + token++) + ":" + Length); vCryB.append("inline"); vCryB.append("|"); vCryB.append(s); vCryB.append("|"); vCryB.append((j++ + token++) + ":" + Length); tst--; if (c <= token) { if(tst>0){ vCryA.append(";"); vCryB.append(";"); } } } System.out.println(vCryA); System.out.println(vCryB); } return value; } public static void main(String[] args) { new test(); } } |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Detecting Object Problems | Lokesh M | AJAX & XML | 0 | 03-10-2008 05:15 AM |
| problems for ora9i administrator | anythinga | Oracle | 0 | 01-23-2008 10:01 AM |
| Has anyone faced this Situation | christia | Companies | 3 | 05-09-2007 07:42 AM |
| Microsoft CRM 3.0 problems | F2F Geek | Get Together | 0 | 01-30-2007 10:05 AM |
| weighting problems... | psuresh1982 | Brainteasers | 4 | 01-02-2007 05:06 AM |