Prac_4_30971.docx - PRACTICAL-4 ID:170030971 4A BYTE...

This preview shows page 1 - 6 out of 6 pages.

PRACTICAL-4 ID:170030971 4A) BYTE STUFFING: import java.util.*; class CN4A { public static void main(String[] args) { System.out.println("Enter the input string"); Scanner sc=new Scanner(System.in); String st=sc.nextLine(); System.out.println("original Data: "+st); sender(st); } public static void sender(String st) { int pos=0; pos=st.indexOf("dle"); if(pos==0) { System.out.println("Transmitted data: "+("dlestx"+st+"dleetx")); } Else {
Image of page 1

Subscribe to view the full document.

StringBuffer sb=new StringBuffer(st); sb.insert(pos+3,"dle"); String s2="dlestx"+sb+"dleetx"; System.out.println("Transmitted data: "+("dlestx"+sb+"dleetx")); receiver(s2); } } public static void receiver(String st) { StringBuffer s=new StringBuffer(st); s.delete(0,6); int len=s.length(); s.delete(len-6,len); int pos=0; pos=s.indexOf("dle"); if(pos==0) System.out.println("Received data is: "+s); else{ s.delete(pos,pos+3); System.out.println("Received data is: "+s); } } }
Image of page 2
OUTPUT: 4B) BIT STUFFING: import java.util.Scanner; class CN4B { public static void main(String[] args)throws java.lang.StringIndexOutOfBoundsException
Image of page 3

Subscribe to view the full document.

Image of page 4
Image of page 5

Subscribe to view the full document.

Image of page 6
  • Spring '17
  • prsad
  • Scanner sc, 01111110

{[ snackBarMessage ]}

Get FREE access by uploading your study materials

Upload your study materials now and get free access to over 25 million documents.

Upload now for FREE access Or pay now for instant access
Christopher Reinemann
"Before using Course Hero my grade was at 78%. By the end of the semester my grade was at 90%. I could not have done it without all the class material I found."
— Christopher R., University of Rhode Island '15, Course Hero Intern

Ask a question for free

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern