Professional Documents
Culture Documents
Bowlingprogrambowlers Bprgbjava
Bowlingprogrambowlers Bprgbjava
ahmed;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import com.testing.ahmed.PlayGame.Match;
import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.Random;
import java.util.Scanner;
*/
private String name;
private int runscoredperballandoutcomeperballinaOver;
private int overbowlingnumberofballs;//6 balls per over
/*
name[0]="Kirat Boli";
name[1]="N.S. Nodhi";
name[2]="R Rumrah";
name[3]="Shashi Henra";
*/
if (batsmanflag==1) {
System.out.println("bowler "+ option +"bowling. A ball is bowled.
Batsman 1 is batting");
System.out.println("The Score is - "+Match.Currentscore +"runs
and "+ Match.Currentwickets + " wickets");
} else if (batsmanflag==2) {
System.out.println("bowler "+ option +"bowling. A ball is bowled.
Batsman 2 is batting");
System.out.println("The Score is - "+Match.Currentscore +"runs
and "+ Match.Currentwickets + " wickets");
}
if ((Match.Currentscore>=40) && (Match.Currentwickets<3) &&
(Match.ballsbowled<=36)) {
System.out.println("Lengaburu
wins!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
Match.WinnerFlag=1;
} else if ((Match.Currentscore==40) && (Match.Currentwickets<=3) &&
(Match.ballsbowled<=36)) {
System.out.println("ITS A
TIE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
Match.WinnerFlag=0;
} else if ((Match.Currentscore<40) && (Match.Currentwickets>=3) &&
(Match.ballsbowled<=36)) {
System.out.println("Enchai
Wins!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
Match.WinnerFlag=2;
}
}
String Commentary="";
int runsscored=0;
int equationmatchscorerunsscoredwicketstakenwicketsremaining[]=new
int[2];
int matchscore=0;
int wickets=0;
int wicketstakenflag=0;
int equationmatchscorerunsscored=40; // read from properties file
int equationwicketstakenwicketsremaining=3;
int i=0;
int j=0;
int overnumber[]=new int[4];
int scoreandwicketsforover[]=new int[12]; //do read from properties
file
int option;
option=bowler;
/*for(i=0;i<4;i++) {
overnumber[i]=Match.Currentmatchbowlerordersequence[i];
}*/
if (matchesplayed>0) {
scoreandwicketsforover=
readbowlersequence(overorderforeverybowler, bowleroutcome, matchesplayed); //Async
-to read from generated file
} else {
scoreandwicketsforover= bowleroutcome;//Sync
}
int jcntr;
jcntr=0;
j=matchesplayed*6;
int jcntrlength;
jcntrlength=0;
jcntrlength=j+6;
int batsmanflag;
batsmanflag=1;
for (jcntr=j;jcntr<jcntrlength;jcntr++) {
if (scoreandwicketsforover[jcntr]==0) {
runsscored=runsscored+0;
Match.Currentscore=Match.Currentscore+0;
batsmanflag=1;
equationmatchscorerunsscored=equationmatchscorerunsscored-0;
printScore(option,runsscored,wickets,batsmanflag);
}
else if(scoreandwicketsforover[jcntr]==1) {
runsscored=runsscored+1;
Match.Currentscore=Match.Currentscore+1;
batsmanflag=2;
equationmatchscorerunsscored=equationmatchscorerunsscored-1;
printScore(option,runsscored,wickets,batsmanflag);
}
else if(scoreandwicketsforover[jcntr]==2) {
runsscored=runsscored+2;
Match.Currentscore=Match.Currentscore+2;
batsmanflag=1;
equationmatchscorerunsscored=equationmatchscorerunsscored-2;
printScore(option,runsscored,wickets,batsmanflag);
}
else if(scoreandwicketsforover[jcntr]==3) {
runsscored=runsscored+3;
Match.Currentscore=Match.Currentscore+3;
batsmanflag=2;
equationmatchscorerunsscored=equationmatchscorerunsscored-3;
printScore(option,runsscored,wickets,batsmanflag);
}
else if(scoreandwicketsforover[jcntr]==4) {
runsscored=runsscored+4;
Match.Currentscore=Match.Currentscore+4;
batsmanflag=1;
equationmatchscorerunsscored=equationmatchscorerunsscored-4;
printScore(option,runsscored,wickets,batsmanflag);
}
else if(scoreandwicketsforover[jcntr]==5) {
runsscored=runsscored+5;
Match.Currentscore=Match.Currentscore+5;
batsmanflag=2;
equationmatchscorerunsscored=equationmatchscorerunsscored-5;
printScore(option,runsscored,wickets,batsmanflag);
}
else if(scoreandwicketsforover[jcntr]==6) {
runsscored=runsscored+6;
Match.Currentscore=Match.Currentscore+6;
batsmanflag=1;
equationmatchscorerunsscored=equationmatchscorerunsscored-6;
printScore(option,runsscored,wickets,batsmanflag);
}
else if(scoreandwicketsforover[jcntr]==-1) {
wickets=wickets+1;
Match.Currentwickets=Match.Currentwickets+1;
batsmanflag=2;
equationwicketstakenwicketsremaining=equationwicketstakenwicketsremaining-1;
wicketstakenflag=1;
printScore(option,runsscored,wickets,batsmanflag);
}
Match.ballsbowled=Match.ballsbowled+1;
} //for 1 over
equationmatchscorerunsscoredwicketstakenwicketsremaining[1]=Match.Currentwickets+eq
uationmatchscorerunsscoredwicketstakenwicketsremaining[1];
} else if (Match.Currentscore<40){
equationmatchscorerunsscoredwicketstakenwicketsremaining[0]=Match.Currentscore+equa
tionmatchscorerunsscoredwicketstakenwicketsremaining[0];
}
int result;
result=0;
int runs;
runs=Match.Currentscore;
int wickets;
wickets=Match.Currentwickets;
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!ITS A TIE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
result=0;
} else if ((Match.Currentscore>=40) && (Match.Currentwickets<3) &&
(icntr<=4) && (Match.ballsbowled>=36)) {
System.out.println("Lengaburu
Wins!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
result=1;
} else if ((Match.Currentscore<40) && (Match.Currentwickets>=3) &&
(icntr<=4) && (Match.ballsbowled>=36)) {
System.out.println("Enchai
Wins!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
result=2;
} else if ((Match.Currentscore<40) && (Match.Currentwickets<=3) &&
(icntr<=4) && (Match.ballsbowled>=36)) {
System.out.println("Enchai
Wins!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
result=2;
}
return result;
//orderofrunscoredperballandoutcomeperballinaOver=Math.random()*0.8*100;
int bowlingcntr;
bowlingcntr=1;
double randombowlingoutcome;
int seed;
seed=8;
int countersofbowler1[]={5,30,25,10,15,1,9,5};
int countersofbowler2[]={10,40,20,5,10,1,4,10};
int countersofbowler3[]={20,30,15,5,5,1,4,20};
int countersofbowler4[]={30, 25,5,0,5,1,4,30};
int passrunningover;
passrunningover=over;
/*
* int bowler1cntr[]={0,45,270,225,90,135,9,81,45}; int
* bowler2cntr[]={0,90,360,180,45,90,9,36,90}; int
* bowler3cntr[]={0,180,270,135,45,45,9,36,180}; int
* bowler4cntr[]={0,270,225,45,0,45,9,36,270};
*/
int i;
i=1;
System.out.println("bowler -"+bowler);
int bowlercntr;
bowlercntr=1;
int cntr;
cntr=0;
// bowler 1 sequence
//static int cntr1, cntr2,cntr3, cntr4, cntr5, cntr6, cntr7, cntr8;
String score;
score="";
score="<score>"+"<bowler>"+bowler+"</bowler>";
String source;
source=Match.Matchstatistics;
int wickets;
wickets=0;
int matchscore;
matchscore=0;
int oversbowled;
oversbowled=0;
oversbowled=over;
score=score+"<over>";
if (matchesplayed>0) {
bowlercoutcome = readbowlersequence(bowlercntr, bowlercoutcome,
matchesplayed);
}
int batsmanflag;
batsmanflag=1;
if (matchesplayed==0) {
bowlingcntr = genRandomNumber.generateRandomNumber();//TO
GENERATE RANDOM ORDER OF SCORE
}
if ((bowlercntr>=6) && ((bowlercntr%6)==0)){//increment overs by
1
oversbowled=oversbowled+1;
score=score+oversbowled+"</over>";
score=score+"<rorwoutcomeresult>"+0+"</rorwoutcomeresult>";
//runorwicketoutcomeresult
Match.Currentscore=Match.Currentscore+0;
printScore(bowler,Match.Currentscore,Match.Currentwickets,batsmanflag);
} else if (bowlingcntr>=12.5 && bowlingcntr<25)
{
cntr=bowlerselected[2];
//cntr=cntr-1;
if (cntr>0){
outcome[bowlercntr]=1;//1 run
cntr=cntr-1;
bowlerselected[2]=bowlerselected[2]-1;
}
//matchscore=matchscore+1;
score=score+"<ball>"+bowlercntr+"</ball>";
score=score+"<rorwoutcomeresult>"+1+"</rorwoutcomeresult>";
Match.Currentscore=Match.Currentscore+1;
batsmanflag=2;
printScore(bowler,Match.Currentscore,Match.Currentwickets,batsmanflag);
} else if (bowlingcntr>=25 && bowlingcntr<37.5)
{
cntr=bowlerselected[3];
//cntr=cntr-1;
if (cntr>0){
outcome[bowlercntr]=2;//2 run
cntr=cntr-1;
bowlerselected[3]=bowlerselected[3]-1;
}
//matchscore=matchscore+2;
score=score+"<ball>"+bowlercntr+"</ball>";
score=score+"<rorwoutcomeresult>"+2+"</rorwoutcomeresult>";
Match.Currentscore=Match.Currentscore+2;
printScore(bowler,Match.Currentscore,Match.Currentwickets,batsmanflag);
} else if (bowlingcntr>=37.5 && bowlingcntr<50)
{
cntr=bowlerselected[4];
//cntr=cntr-1;
if (cntr>0){
outcome[bowlercntr]=3;//3 run
cntr=cntr-1;
bowlerselected[4]=bowlerselected[4]-1;
}
//matchscore=matchscore+3;
score=score+"<ball>"+bowlercntr+"</ball>";
score=score+"<rorwoutcomeresult>"+3+"</rorwoutcomeresult>";
Match.Currentscore=Match.Currentscore+3;
batsmanflag=1;
printScore(bowler,Match.Currentscore,Match.Currentwickets,batsmanflag);
} else if (bowlingcntr>=50 && bowlingcntr<62.5)
{
cntr=bowlerselected[5];
//cntr=cntr-1;
if (cntr>0){
outcome[bowlercntr]=4;//4 run
cntr=cntr-1;
bowlerselected[5]=bowlerselected[5]-1;
}
//matchscore=matchscore+4;
score=score+"<ball>"+bowlercntr+"</ball>";
score=score+"<rorwoutcomeresult>"+4+"</rorwoutcomeresult>";
Match.Currentscore=Match.Currentscore+4;
printScore(bowler,Match.Currentscore,Match.Currentwickets,batsmanflag);
} else if (bowlingcntr>=62.5 && bowlingcntr<75)
{
cntr=bowlerselected[6];
//cntr=cntr-1;
if (cntr>0){
outcome[bowlercntr]=5;//5 run
cntr=cntr-1;
bowlerselected[6]=bowlerselected[6]-1;
}
//matchscore=matchscore+5;
score=score+"<ball>"+bowlercntr+"</ball>";
score=score+"<rorwoutcomeresult>"+5+"</rorwoutcomeresult>";
Match.Currentscore=Match.Currentscore+5;
batsmanflag=2;
printScore(bowler,Match.Currentscore,Match.Currentwickets,batsmanflag);
} else if (bowlingcntr>=75 && bowlingcntr<87.5)
{
cntr=bowlerselected[7];
//cntr=cntr-1;
if (cntr>0){
outcome[bowlercntr]=6;//6 run
cntr=cntr-1;
bowlerselected[7]=bowlerselected[7]-1;
}
//matchscore=matchscore+6;
score=score+"<ball>"+bowlercntr+"</ball>";
score=score+"<rorwoutcomeresult>"+6+"</rorwoutcomeresult>";
Match.Currentscore=Match.Currentscore+6;
printScore(bowler,Match.Currentscore,Match.Currentwickets,batsmanflag);
} else if (bowlingcntr>=87.5 &&
bowlingcntr<100) {
cntr=bowlerselected[8];
//cntr=cntr-1;
if (cntr>0){
outcome[bowlercntr]=-1;//1 wicket
cntr=cntr-1;
bowlerselected[8]=bowlerselected[8]-1;
}
//wickets=wickets+1;
score=score+"<ball>"+bowlercntr+"</ball>";
score=score+"<rorwoutcomeresult>"+-1+"</rorwoutcomeresult>";
Match.Currentwickets=Match.Currentwickets-1;
batsmanflag=1;
printScore(bowler,Match.Currentscore,Match.Currentwickets,batsmanflag);
}
bowlercntr=bowlercntr+1;
score=score+"</score>";
return outcome;
}
//write in file
/* String workoutputfilestr = "C:\\Webserver\\Outputfileexcelsheet.csv";
String counterfilecntr = "C:\\Webserver\\cntrfile_cntrfile.txt";
String tempfiletmp = "C:\\Webserver\\tempfile_tmpfile.txt";
*/
int over;
//String score;
//score="";
String sequencepatternstrfile;
sequencepatternstrfile="";
int int_counter_read_read;
int_counter_read_read=0;
//read the input sequence and pattern, if not null make it as 1
int cntr_ctr;
cntr_ctr=0;
int cntrflag;
cntrflag=0;
int CurrentMatchOvericntr;
CurrentMatchOvericntr=1;
//CurrentMatchOvericntr=over;
try {
if(!file.exists()){
file.createNewFile();
}
//score=score+"</score>";
pw.print(score);
pw.close();
} catch (IOException e) {
e.printStackTrace();
}
//return outcome;
int counter;
counter=0;
counter=bowler;
String bowlersequence;
//check match statistics
int overnumber[] = new int[4];//read from MatchStatsmatchstatistics.txt
//matchesplayed=Match.matchesplayed;
oversbowled=matchesplayed;
int i;
i=0;
//do generate order of bowlers by reading from dest file as per this
order
for(i=0;i<4;i++) {
overnumber[i]=Match.Currentmatchbowlerordersequence[i];//read
from properties file or its equal to matchesplayed assuming 1 over for each bowler
}
String bowlersourceinput;
bowlersourceinput="";
bowlersourceinput="bowler"+bowler+"sequenceandpatternfile.txt";
if (matchesplayed>0) {
int kxcntr;
int jxcntr;
int zxcntr;
jxcntr=0;
kxcntr=0;
zxcntr=0;
kxcntr=matchesplayed*6;
kxcntr=kxcntr+1;
for(jxcntr=kxcntr;jxcntr<=kxcntr;jxcntr++) {
scoreandwickets[zxcntr]=readbowleroverfromfilegenerateover(bowler,
bowlersourceinput, oversbowled, matchesplayed);
zxcntr=zxcntr+1;
}
} else {
scoreandwickets=bowleroutcome;
}
try {
String dest;
dest="";
dest ="D:\\kirkaet\\match"+matchesplayed+"matchresultscore.txt";
if(!matchresultscorefile.exists()){
matchresultscorefile.createNewFile();
}
String scoreoutcome;
String runsorwicketoutcome;
runsorwicketoutcome="";
scoreoutcome="<match><score>";
scoreoutcome="<bowler>"+bowler+"<bowler>";
int j;
int jcntr;
j=0;
jcntr=matchesplayed*6;
for(jcntr=j;jcntr<j;jcntr++) {
runsorwicketoutcome="<ball>"+jcntr+"</ball>";
runsorwicketoutcome="<runsorwicketoutcome>"+scoreandwickets[j]
+"</runsorwicketoutcome>";
j++;
}
scoreoutcome=scoreoutcome+runsorwicketoutcome+"<match/></score>";
pwmrsfp.print(scoreoutcome);
pwmrsfp.close();
bwmrsfp.close();
fwmrsfp.close();
} catch (IOException e) {
e.printStackTrace();
}
//generate bowler sequence
//bowlersequence =
int currentgenerateMatchoverssequencecntr;
currentgenerateMatchoverssequencecntr=matchesplayed;
return scoreandwickets;
}
int scoreint_cntr_read_read;
scoreint_cntr_read_read=0;
int int_cntr_read_read;
int_cntr_read_read=0;
int cntr_read_readflag;
cntr_read_readflag=0;
int int_cntr_read_write_flag;
int_cntr_read_write_flag=0;
if (cntr_f.exists()) {
try {
StringBuilder cntrcontentBuilder = new StringBuilder();
BufferedReader br = new BufferedReader(new
FileReader(bowlercntrfilesourcenoorplayBallMatchComeon));
try {
String scntrCurrentLine = null;
while ((scntrCurrentLine = br.readLine()) != null) {
cntrcontentBuilder.append(scntrCurrentLine);
cntr_read_readflag=1;
}
} catch (IOException e) {
e.printStackTrace();
}
br.close();
try {
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(cntr_read_read);
System.out.println("cntr_read_read - " + cntr_read_read);
int x;
x=0;
if (m.find()) {
System.out.println("positionstartarray - " +
positionstartarray[x]);
x = x + 1;
int y;
y=0;
try {
Pattern pclose = Pattern.compile(regexxmlend);
Matcher mclose = pclose.matcher(cntr_read_read);
System.out.println("cntr_read_read - " + cntr_read_read);
if (mclose.find()) {
y = y + 1;
String ballandrunscounterpropertystring;
ballandrunscounterpropertystring="";
int k;
k=0;
k=matchesplayed; //number of overs bowled
//read the <ball> and <rorwoutcomeresult> result data into an
array
ballandrunscounterpropertystring=cntr_read_read.substring(positionendarray[k],cntr_
read_read.length());
int xcntr;
xcntr=0;
// while (xcntr<=6) {
int positionstartarrayballsandruns[] = {0,0,0,0,0,0};//read the
runs scored or wickets taken
String regexballsandruns="";
//xcntr=xcntr+1;//balls
regexballsandruns = "<rorwoutcomeresult>";
try {
if (mballsandruns.find()) {
positionstartarrayballsandruns[xcntr] =
mballsandruns.end()+1; // <counter> -- //bowler1cntr
System.out.println("positionstartarrayballsandruns -"
+ positionstartarrayballsandruns[xcntr]);
System.out.println("positionstartarrayballsandruns -
" + positionstartarrayballsandruns[xcntr]);
xcntr = xcntr + 1;
try {
Pattern pballsandrunsend =
Pattern.compile(regexballsandruns);
Matcher mballsandrunsend =
pballsandrunsend.matcher(ballandrunscounterpropertystring);
System.out.println("ballandrunscounterendpropertystring - " +
ballandrunscounterpropertystring);
if (mballsandrunsend.find()) {
positionendarrayarrayballsandruns[ycntr] =
mballsandrunsend.start()-1; // <counter> -- //bowler1cntr
System.out.println("positionendarrayarrayballsandruns -" +
positionendarrayarrayballsandruns[ycntr]);
System.out.println("positionendarrayarrayballsandrunss - " +
positionendarrayarrayballsandruns[ycntr]);
ycntr = ycntr + 1;
System.out.println("Pattern created:
"+pballsandrunsend.pattern());
while (zcntr<1) {
runsorwicketandrunscounterproperty=ballandrunscounterpropertystring.substring(posit
ionstartarrayballsandruns[zcntr],positionendarrayarrayballsandruns[zcntr]-1);
if (cntr_read_readflag==1) {
scoreint_cntr_read_read=
Integer.parseInt(runsorwicketandrunscounterproperty);
}else {
scoreint_cntr_read_read=0;
}
zcntr=zcntr+1;
}
} catch (Exception e) {
e.printStackTrace();
}
return scoreint_cntr_read_read;
/**********
File cntrfilesourcenoorlightplayBallMatchfile= new
File(cntrfilesourcenoorlightplayBallMatchfilepath);
String propertyfilefilepath;
propertyfilefilepath="";
try {
propertyfilefilepath=cntrfilesourcenoorlightplayBallMatchfile.getCanonicalPath();
} catch (IOException e) {
e.printStackTrace();
}
int int_cntr_read_read;
int_cntr_read_read=0;
int cntr_read_readflag;
cntr_read_readflag=0;
int int_cntr_read_write_flag;
int_cntr_read_write_flag=0;
if (cntrNew_f.exists()) {
try {
StringBuilder cntrcontentBuilder = new StringBuilder();
BufferedReader br = new BufferedReader(new
FileReader(cntrfilesourcenoorlightplayBallMatchfile));
try {
br.close();
****/
String counter;
counter="";
counter=patternmatch;
String str;
str="";
try {
try {
System.out.print(str);
in.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (in != null)
in.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
}
String cntr_read_read;
cntr_read_read = str;
int cntr_read_readflag;
cntr_read_readflag=0;
int int_cntr_read_read;
int_cntr_read_read=0;
if (str=="") {
cntr_read_readflag=0;
} else {
cntr_read_readflag=1;
}
try {
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(cntr_read_read);
if (m.find()) {
System.out.println("positionstartarray - " +
positionstartarray);
x = x + 1;
}
} catch (PatternSyntaxException pse) {
pse.getMessage();
}
String regexxmlend = "";
regexxmlend = "</"+ counter +">";
try {
Pattern pclose = Pattern.compile(regexxmlend);
Matcher mclose = pclose.matcher(cntr_read_read);
System.out.println("cntr_read_read - " + cntr_read_read);
y = y + 1;
}
} catch (PatternSyntaxException pse) {
pse.getMessage();
}
String counterproperty;
counterproperty="";
counterproperty=cntr_read_read.substring(positionstartarray,positionendarray-
1);
System.out.println("counterproperty - "+patternmatch + "-
"+counterproperty);
if (counterproperty.isEmpty()) {
int_cntr_read_read=-1;
}else {
int_cntr_read_read=Integer.parseInt(counterproperty);
}
return int_cntr_read_read;
//propertiesfile
//Match Statistics file "D:\\kirkaet\\MatchStatsandmatchstatistics.txt"
/*
* String propertyfilefilepath; propertyfilefilepath=""; try {
* propertyfilefilepath=propertyfile.getCanonicalPath(); } catch
(IOException e)
* { e.printStackTrace(); }
*/
int cntr_read_readflag;
cntr_read_readflag=0;
int incordec;
incordec=1; //1 means increment, -1 means decrement
incordec=inc;
int int_cntr_read_write_flag;
int_cntr_read_write_flag=0;
if (cntr_f.exists()) {
try {
StringBuilder cntrcontentBuilder = new StringBuilder();
BufferedReader br = new BufferedReader(new
FileReader(counterfilecntr));
try {
br.close();
try {
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(cntr_read_read);
System.out.println("cntr_read_read - " + cntr_read_read);
if (m.find()) {
x = x + 1;
if (mclose.find()) {
y = y + 1;
String counterproperty;
counterproperty="";
counterproperty=cntr_read_read.substring(positionstartarray,positionendarray);
if (cntr_read_readflag==1) {
int_cntr_read_read= Integer.parseInt(counterproperty);
}else {
int_cntr_read_read =0;
}
int old_int_cntr_read_read;
old_int_cntr_read_read=0;
if (incordec==1) {
old_int_cntr_read_read=int_cntr_read_read;
int_cntr_read_read=int_cntr_read_read+1; //decrement
counter by 1 till its greater than 0
} else if (incordec==-1) {
old_int_cntr_read_read=int_cntr_read_read;
int_cntr_read_read=int_cntr_read_read-1; //decrement
counter by 1 till its greater than 0
}
String new_cntr_read_read;
new_cntr_read_read="";
String regexxmlcounterstr;
regexxmlcounterstr="";
regexxmlcounterstr="<"+ counter +">"+old_int_cntr_read_read+"</"+
counter +">";
String replacement;
replacement="";
replacement="<"+ counter +">"+int_cntr_read_read+"</"+ counter
+">";
new_cntr_read_read=cntr_read_read.replaceFirst(regexxmlcounterstr,
replacement);
if (cntrNew_f.createNewFile()) {
int_cntr_read_write_flag=1;
//outcntrtestfile2.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
if (int_cntr_read_write_flag==1) {
return true;
} else {
return false;
}
}
out.close();
bw.close();
fw.close();
} finally {
// is.close();
// out.close();
System.out.println("the file is closed in previous block");
}
}