123 Eng

Engineering the engineers™


Latest Jobs   Forum Map

 


Home
Source Codes
Engineering Colleges

Training  Reports
Seminar Reports
Placement Papers

Forums

   Computer Science / IT
   Electronics
   Electrical
   Mechanical
   Chemical
   Civil

   CAT / MBA

   GMAT / Foreign MBA
Latest Jobs

Engineering Jobs / Technical Jobs
Management Jobs

Sitemap
Terms of use

Displaying  Source Code(s)  
 

 
String Manipulation Using Stringification

--------------------------------------------------------------------------------

Description : Not Specified

//Strfns.idl//
module Strfns {
interface Op {
float stPos(in string a,in string b);
boolean stComp(in string a,in string b);
float stLen(in string a);
};
};

//Server.java//
import java.io.*;
import org.omg.CORBA.*;
import Strfns.*;
class StringOp extends _OpImplBase {
public float stPos( String a,String b)
{
return (a.indexOf(b));
}
public boolean stComp(String a,String b)
{
return(a.equals(b));
}
public float stLen(String a)
{
return(a.length());
}
}
public class Server
{
public static void main(String args[])
{
try
{
ORB orb = ORB.init(args, null);
StringOp c = new StringOp();
orb.connect(c);
String str = orb.object_to_string(c);
String filename =
System.getProperty("user.home")+System.getProperty("file.separator")+"OpIO
R";
FileOutputStream fos = new FileOutputStream(filename);
PrintStream ps = new PrintStream(fos);
ps.print(str);
ps.close();
System.out.println("The Servant Reference has been Stringified...");
System.out.println("The CORBA Server is up and running...");
Thread.currentThread().join();
}
catch (Exception e)
{
System.err.println("ERROR: " + e);
e.printStackTrace(System.out);
}
}
}

//Client.java//
import java.io.*;
import org.omg.CORBA.*;
import Strfns.*;
import java.lang.String.*;
public class Client {
public static void main(String args[]) {
try
{
ORB orb = ORB.init(args, null);
String filename =
System.getProperty("user.home")+System.getProperty("file.separator")+"OpIO
R";
java.io.FileInputStream tis = new java.io.FileInputStream(filename);
java.io.DataInputStream is = new java.io.DataInputStream(tis) ;
String or = is.readLine() ;
org.omg.CORBA.Object obj1 = orb.string_to_object(or) ;
Op cOp = OpHelper.narrow(obj1);
System.out.println("
STRING FUNCTIONS");
System.out.println("Select one option");
System.out.println("1.position
2.comparison
3.length");
BufferedReader in = new BufferedReader(new
InputStreamReader(System.in));
int k=Integer.parseInt(in.readLine());
System.out.println("Enter the strings:");
String a=in.readLine();
String b=in.readLine();
switch(k)
{
case 1:
{
System.out.println(" Sting Concatenation = " + cOp.stPos(a,b));
}
case 2:
{
System.out.println(" String Comparison = " + cOp.stComp(a,b));
}
case 3:
{
System.out.println(" String Length = " + cOp.stLen(a));
}
}
}
catch (Exception e)
{
System.out.println("ERROR : " + e) ;
e.printStackTrace(System.out);
}
}
}

 

Contribute content or training reports / feedback / Comments
job placement papers
All rights reserved copyright 123ENG