import org.omg.CosNaming.*; import java.io.*; public class Client { public static void main(String args[]) { try { org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null); if (args.length == 0) { System.out.println("Usage: Client "); System.exit(-1); } File f = new File( args[ 0 ] ); if( ! f.exists() ) { System.out.println("File " + args[0] + " does not exist."); System.exit( -1 ); } BufferedReader br = new BufferedReader( new FileReader( f )); String ior = br.readLine(); br.close(); ls lsObj = lsHelper.narrow(orb.string_to_object(ior)); EasyReader console = new EasyReader(); int size; System.out.println("Enter size of sequence to send"); size = console.readInt(); byte[] sendData = new byte[size]; System.out.println("Creating a sequence of " + size + " bytes with values from 0 to 9"); for (int i = 0; i < size; i++) { sendData[i] = (byte)(i % 10); } lsObj.sendData(sendData); System.out.println("Getting a sequence with values 0 to 255"); sendData = lsObj.getData(size); // Note that all primitive int types, including bytes are signed in java. // To have the byte value 0xff display as 255, you need to promote it to // an int and then chop off the high order bits incase sign extension occurred. int ui = sendData[sendData.length - 1]; ui = ui & (int)0xFF; System.out.println("Got sequence of " + sendData.length + " bytes. Last element is " + // This works too ... //new Integer(sendData[sendData.length - 1] & 0xFF )); ui); } catch (Exception e) { e.printStackTrace(); } } }