Java Programming Example of how to convert string into bytes?

This program accepts the string from the keyboard and convert the string into bytes and displays the bytes.

import java.io.*;

/**
 *
 * @author JavaHotSpot
 */

public class stringtoBytes
{
  public static void main(String args[])
 {
     String s1;
     int length;
     byte[] b;
     DataInputStream d;
     try
     {
     System.out.println("Enter the String");
     d=new DataInputStream(System.in);
     s1=(String)d.readLine();
     b=s1.getBytes();
     System.out.println("The bytes are");
     for(int i=0;i<b.length;i++)
     {
         System.out.println(b[i]);
     }
     }
     catch(Exception e)
     {
         System.out.println(e.toString());
     }
 }
}

Output:
Enter the String
Java
The bytes are
74
97
118