java - Get message 'deprecated APIs' in GoBackN client/server programs -
java - Get message 'deprecated APIs' in GoBackN client/server programs -
my s/w simulation of goback n protocol gives warning- [deprecation] readline() in datainputstream has been deprecated
(while reading streams) while running both client & server programs .please tell me solution.is there alternative readline()
? here client/server programs
//server programme import java.io.*; import java.net.*; import java.lang.*; public class gobacksender { public static void main(string[] args)throws exception { //establishing connection serversocket ss=new serversocket(4444); system.out.println("waiting connection........"); socket s=ss.accept(); system.out.println("connected client at:"+s); datainputstream in=new datainputstream(system.in); datainputstream in1=new datainputstream(s.getinputstream()); printstream p=new printstream(s.getoutputstream()); int sptr=0,sws=8,i,ano,nf,n; string sbuf[]=new string[8]; string ch,ch1; system.out.println("enter no.of frames"); nf=integer.parseint(in.readline()); p.println(nf); if(nf<=sws-1) { system.out.println("enter "+nf+" messages send"); for(i=1;i<=nf;i++) { sbuf[sptr]=in.readline(); p.println(sbuf[sptr]); sptr=++sptr%8; } sws-=nf; { ano=integer.parseint(in.readline()); system.out.println("received acknowledgement for:"+ano); system.out.println("retransmitting..............."); for(i=ano-1;i<nf;i++) p.println(i); ch1=in1.readline(); }while(ch1.equals("yes")); sws+=nf; } else { system.out.println("the no.of frames exceed window size"); } ano=integer.parseint(in1.readline()); system.out.println("acknowledgement received for"+ano+"frames"); s.close(); } } //client programme import java.io.*; import java.net.*; import java.lang.*; public class gobackreceiver { public static void main(string[] args)throws exception { //connection establishment socket s=new socket("localhost",4444); system.out.println("connected server at:"+s); datainputstream in=new datainputstream(system.in); datainputstream in1=new datainputstream(s.getinputstream()); printstream p=new printstream(s.getoutputstream()); string rbuf[]=new string[8]; int i,rptr=0,rws=8,nf,n; string ch,ch1; { nf=integer.parseint(in1.readline()); system.out.println("no.of messages",nf); if(nf<rws) { for(i=1;i<=nf;i++) { rbuf[rptr]=in1.readline(); rptr=++rptr%8; system.out.println("the received frame"+(rptr+1)+"is:"+rbuf[rptr]); } rws-=nf; { system.out.println("enter nak number"); n=integer.parseint(in.readline()); if((1<=n)&&(n<=nf)) { p.println(n); for(i=n;i<nf;i++) { rbuf[i]=in1.readline(); system.out.println("the received frame"+i+"is;"+rbuf[i]); } } else { system.out.println("invalid nak"); } system.out.println("anymore frames lost?"); ch1=in.readline(); p.println(ch1); }while(ch1.equals("yes")); system.out.println("ack sent"); p.println(rptr+1); rws+=nf; } else break; ch=in.readline(); }while(ch.equals("yes")); s.close(); } }
copied java api docs: deprecated. method not convert bytes characters. of jdk 1.1, preferred way read lines of text via bufferedreader.readline() method. programs utilize datainputstream class read lines can converted utilize bufferedreader class replacing code of form:
datainputstream d = new datainputstream(in);
with:
bufferedreader d = new bufferedreader(new inputstreamreader(in));
if such warnings, first should on api or @ to the lowest degree googling..
java
Comments
Post a Comment