Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem faced in execution

 
jeya prabha
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, please UseCodeTags. It makes your code more readable.

Second, we are NotACodeMill. We will not provide you with all the answers, you have to do the main work yourself. We will only point you in the right direction.

Third, please EaseUp. There is no need for the "ASAP". We are all volunteers who are not being paid for posting here, so you can't demand that we put everything down to help you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic