-
Junior Member
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
-
Junior Member
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();
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules