How to communicate two objects in java

pls reply to this mail

>>
http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi
?ubb=get_topic&f=1&t=012041
Communicate between forum.java.sun and Java Ranch?Communicate with the heathens at Java Ranch?

Similar Messages

  • How to compare two files in java & uncommon text should print in text file.

    Hi,
    Can any one help me to write Core java program for this.
    How to compare two files in java & uncommon text should print in other text file.
    thanks
    Sam

    Hi All,
    i m comparing two HTML file.. thats why i am getting problem..
    import java.io.BufferedReader;
    import java.io.FileReader;
    public class textmatch{
    public static void main(String[] argv)
    throws Exception{
    BufferedReader fh =new BufferedReader(new FileReader("internal.html"),1024);
    BufferedReader sh = new BufferedReader(new FileReader("external.html"),1024);
    String s;
    String y;
    while ((s=fh.readLine())!=null)
    if ( s.equals(y=sh.readLine()) ){    
    System.out.println(s + " " + y); //REMOVE THIS PRINTLN STATEMENT IF YOU JUST WANT TO SHOW THE SIMILARITIES
    sh.close();
    fh.close(); }
    thanks
    Sam

  • How to compare two files in Java & uncommon text should print in Diff text

    Hi All,
    can any one help me to write a java program..
    How to compare two files in Java & uncommon text should print in Diff text file..
    Thanks
    Sam

    Hi All,
    i m comparing two HTML file.. thats why i am getting problem..
    import java.io.BufferedReader;
    import java.io.FileReader;
    public class textmatch{
    public static void main(String[] argv)
    throws Exception{
    BufferedReader fh =new BufferedReader(new FileReader("internal.html"),1024);
    BufferedReader sh = new BufferedReader(new FileReader("external.html"),1024);
    String s;
    String y;
    while ((s=fh.readLine())!=null)
    if ( s.equals(y=sh.readLine()) ){    
    System.out.println(s + " " + y); //REMOVE THIS PRINTLN STATEMENT IF YOU JUST WANT TO SHOW THE SIMILARITIES
    sh.close();
    fh.close(); }
    thanks
    Sam

  • How to compare two Objects !!!!

    Hi All,
    I know that this question has been asked 100 times till now. But trust me I have checked all of them but couldn`t find answer. Here is my question:
    I have an objecs. In that object I am setting (Id,Name,DOJ). Now I want to check whether the object I am trying to save in database already exists or not. If exists then I need to check whether all the setters are same for the two objects. Now can anyone tell me ,how to compare two objects directly without comparing the setters individually.
    Thanks in advance.

    pavan13 wrote:
    That is pretty good idea. However I have a query. Does that code actually compare all the setters in a two beans. I don`t want to check each setter seperately.Well, it's pretty meaningless to talk about "comparing setters", setters are methods, they don't have values to compare. Because equals is inside the class, you can simply compare the fields that get set by the setters. "Properties" is probably a better name.
    In principal you could write something that tried to find all relevant fields and compare them, using reflection or bean info stuff. The resulting code would be about 50 times longer and take about 50 times longer to run. It's hardly asking a lot to put three comparisons between && operators.
    Remember, though, not to compare string fields with ==, you should call .equals on the string fields.
    p.s. don't let the bean terminology confuse you. Beans are just ordinary objects which follow a few rules. Personally I wish the term had never been coined.
    Edited by: malcolmmc on Dec 6, 2007 4:15 PM

  • How to add two objects on scene and how to rotate them?

    I am beginer on 3d. I am trying do write applet where are 3x3x3 rubic.
    My plans are to have 27 litle cubes. There are 6 flats (9 cubes in a flat) so i have six objects groups. My problem at this moment is that i cant find out how to make two objets. Each of this two objects consists from couple more litle objects. Some of litle objects can be in first and second big object. For example it can be two flats of rubic (corner).
    Is anybody have some examples or somehow to hepl me to find out.
    Thanks a lot

    I have code :
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import com.sun.j3d.utils.applet.MainFrame;
    import com.sun.j3d.utils.behaviors.mouse.*;
    import com.sun.j3d.utils.universe.SimpleUniverse;
    import javax.media.j3d.*;
    import javax.vecmath.AxisAngle4f;
    import javax.vecmath.Color3f;
    import javax.vecmath.Vector3f;
    public class RubicApplet extends Applet implements MouseListener
         TransformGroup objRotate = null;
    public BranchGroup createSceneGraph(SimpleUniverse su,Canvas3D canvas)
         // Create the root of the branch graph
         BranchGroup objRoot = new BranchGroup();
         objRoot.setCapability(BranchGroup.ALLOW_DETACH);
    Transform3D transform = new Transform3D();
         transform.setRotation(new AxisAngle4f(.5f,1f,1f,.5f));
    BoundingSphere behaveBounds = new BoundingSphere();
    // create Cube and RotateBehavior objects
    objRotate = new TransformGroup(transform);
    objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    objRotate.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    objRotate.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
    // Colors
    Color3f gray = new Color3f(0.2f,0.2f,0.2f);
    Color3f red = new Color3f(1.0f,0.0f,0.0f);
    Color3f white = new Color3f(1.0f,1.0f,1.0f);
    Color3f yellow = new Color3f(1.0f,1.0f,0.0f);
    Color3f green = new Color3f(0.0f,1.0f,0.0f);
    Color3f blue = new Color3f(0.0f,0.0f,1.0f);
    Color3f purple = new Color3f(1.0f,0.0f,1.0f);
         // Object possition
    float x=-0.5f;
    float y=-0.5f;
    float z=-0.5f;
    objRoot.addChild(objRotate);
         // colors for: back, front, right, left, bottom, top
    Color3f[] myColors0 = {white,gray,gray,red,blue,gray};
    RCube cube1 = new RCube(myColors0,new Vector3f(x-1,y-1,z-1));
         // colors for: back, front, right, left, bottom, top
    Color3f[] myColors1 = {gray,gray,gray,red,blue,gray};
         RCube cube2 = new RCube(myColors1,new Vector3f(x-1,y-1,z+1));
         // colors for: back, front, right, left, bottom, top
    Color3f[] myColors2 = {gray,yellow,gray,red,blue,gray};
         RCube cube3 = new RCube(myColors2,new Vector3f(x-1,y-1,z+3));
    // colors for: back, front, right, left, bottom, top
    Color3f[] myColors3 = {white,gray,gray,red,gray,gray};
         RCube cube4 = new RCube(myColors3,new Vector3f(x-1,y+1,z-1));
    objRotate.addChild(cube1);
    objRotate.addChild(cube2);
    objRotate.addChild(cube3);
    objRotate.addChild(cube4);
    MouseRotate myMouseRotate = new MouseRotate();
    myMouseRotate.setTransformGroup(objRotate);
    myMouseRotate.setSchedulingBounds(new BoundingSphere());
    objRoot.addChild(myMouseRotate);
    MouseTranslate myMouseTranslate = new MouseTranslate();
    myMouseTranslate.setTransformGroup(objRotate);
    myMouseTranslate.setSchedulingBounds(new BoundingSphere());
    objRoot.addChild(myMouseTranslate);
    MouseZoom myMouseZoom = new MouseZoom();
    myMouseZoom.setTransformGroup(objRotate);
    myMouseZoom.setSchedulingBounds(new BoundingSphere());
    objRoot.addChild(myMouseZoom);
    // Let Java 3D perform optimizations on this scene graph.
    objRoot.compile();
         return objRoot;
    public RubicApplet()
    setLayout(new BorderLayout());
    GraphicsConfiguration config =SimpleUniverse.getPreferredConfiguration();
    Canvas3D canvas3D = new Canvas3D(config);
    canvas3D.addMouseListener(this);
    add("Center", canvas3D);
    SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
    BranchGroup scene = createSceneGraph(simpleU,canvas3D);
         simpleU.getViewingPlatform().setNominalViewingTransform();
    simpleU.addBranchGraph(scene);
    public static void main(String[] args)
    Frame frame = new MainFrame(new RubicApplet(), 600, 600);
         public void mouseClicked(MouseEvent e)
         public void mouseEntered(MouseEvent e)
         public void mouseExited(MouseEvent e)
         public void mousePressed(MouseEvent e)
         public void mouseReleased(MouseEvent e)
    I need to rotate with some event two cubes and with some other event rotate three cubes

  • How to use Oracle objects in java code

    Hi all!
    I'm reading an xls and i need to fill me oracle objects with java code:
    OBJECT_NAME OBJECT_TYPE
    LETTURA_OBJ TYPE
    LETTURA_OBJ TYPE BODY
    In the past weeks i've been using both java code into oracle and oracle objects, but new i need to write those objects with data i read with java, anybody can help me?
    I know that the easiest work around would be to put the data i read from the excel file into a table and then fill the oracle objects, but now i want to learn how to write directly those objects with a command like the following one:
    a sample of the code i'm tryng to write:
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED REPORT."Manage_Excel_ASMBS" AS
    import java.io.*;
    import java.io.IOException;
    import jxl.*;
    public cass ....
    #sql{  variabili_globali.var_ER_F3.Tipo_Lettura := 5}
    thanks,
    Massimo
    Edited by: LinoPisto on 16-mag-2011 16.38

    mmmh i'm not understanding so much....
    well... as i told before i'm working in oracle database environment and i'm developing a java procedure.
    now, i have this object
    CREATE OR REPLACE
    TYPE REPORT.FATTURA_OBJ AS OBJECT (
    POD VARCHAR2(1000),
    ID_FATTURA NUMBER,
    ID_FILE NUMBER,
    COERENZA_EA_F VARCHAR2(1000),
    COERENZA_ER_F VARCHAR2(1000),
    COERENZA_EA_M VARCHAR2(1000),
    COERENZA_EF_M VARCHAR2(1000),
    ANOMALIA VARCHAR2(1000),
    MOTIVO_INVALIDAZIONE VARCHAR2(1000),
    MATRICOLA_CONTATORE VARCHAR2(1000),
    POTENZA_DISPONIBILE VARCHAR2(1000),
    MEMBER PROCEDURE pulisci
    /and i need to work with it inside this procedure:
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED REPORT."Manage_Excel_ASMBS" AS
    import java.io.*;
    import java.io.IOException;
    import java.io.StringWriter;
    public class Manage_Excel_ASMBS
    public static void read_Excel(String inputFile,int var_Id_Caricamento, int var_Id_Distributore, String var_Distributore) throws SQLException, IOException
              **here i need to put what i'm reading inside the excel file into oracle objects**
    /can you please give me a sample ?
    thanks

  • How to use bean objects in java script

    function insertRow()
              var row=1;
              var tbl = document.all("TAU");
         var tr = tbl.rows(row);
         var td = tr.cells(0);
         var td2 = tr.cells(1);
         var td3 = tr.cells(2);
         row++;
         tr = tbl.insertRow();
         tr.setAttribute(false);
         td = tr.insertCell();
         td2 = tr.insertCell();
         td3 = tr.insertCell();
         td.innerHTML = "<html:text property='unit' value ='02' />";
         td2.innerHTML = "<html:text property='unit Id' />" ;
         td3.innerHTML = "<html:text property='unit Type' />" ;
    this is my code, it is basicaly add row at run time thru java scripts. i want to set property of beans with this script , in this code i foun error ie. "can not found bean in nay scope" so plz anybody can tell me how can i pass bean object to java script !!!!!!

    mmmh i'm not understanding so much....
    well... as i told before i'm working in oracle database environment and i'm developing a java procedure.
    now, i have this object
    CREATE OR REPLACE
    TYPE REPORT.FATTURA_OBJ AS OBJECT (
    POD VARCHAR2(1000),
    ID_FATTURA NUMBER,
    ID_FILE NUMBER,
    COERENZA_EA_F VARCHAR2(1000),
    COERENZA_ER_F VARCHAR2(1000),
    COERENZA_EA_M VARCHAR2(1000),
    COERENZA_EF_M VARCHAR2(1000),
    ANOMALIA VARCHAR2(1000),
    MOTIVO_INVALIDAZIONE VARCHAR2(1000),
    MATRICOLA_CONTATORE VARCHAR2(1000),
    POTENZA_DISPONIBILE VARCHAR2(1000),
    MEMBER PROCEDURE pulisci
    /and i need to work with it inside this procedure:
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED REPORT."Manage_Excel_ASMBS" AS
    import java.io.*;
    import java.io.IOException;
    import java.io.StringWriter;
    public class Manage_Excel_ASMBS
    public static void read_Excel(String inputFile,int var_Id_Caricamento, int var_Id_Distributore, String var_Distributore) throws SQLException, IOException
              **here i need to put what i'm reading inside the excel file into oracle objects**
    /can you please give me a sample ?
    thanks

  • How to communicate two PC's with the serial port with Netbeans

    Do you know how to do it?
    Do you know how to communicate with the parallel port too?
    Could you give some ideas?
    What commands or instructions I have to use?

    What does NetBeans have to do with it?
    All these "people" today that start out in Java using all these "nifty" IDE's. All it does is produce exactly this. They think their IDE is Java. Once they no longer have their one specific IDE in front of them, they can no longer function. They have no idea what the classpath, what the compiler actually does, how to package a jarfile, hell, most of the time, they don't even know how to execute a simple application.
    As far as your question. Did you even try to Google for some Serial port API package? Assuming you did, did you download it and read the documentation that comes with it? Did you search for a few examples on the web? Did you read them? Did you try them? I can almost guarantee that the answer to everyone of those questions is "no". So, my question for you is, "Why should we help you?" You obviously have no desire to help yourself, so I think we should reciprocate in kind. Don't you?

  • How to return custJava Object from Java Stored Function/Procedure to Java Application

    I WILL PAY $100 FOR SOLUTION.
    Oracle JDBC documentation gives step by step on how to return Oracle Type Object to Java Application. No question here.
    But is it possible to create Java Stored Function [getMyClass() ] which returns CUSTOM Java based object [MyClass] to Java application like:
    //java stored function
    class Foo
    public static MyClass getMyClass()
    return new MyClass();
    //java class I want to return to Java
    class MyClass
    public String getGreetings(String name)
    return "Hello " + name;
    I tried to do it using intermittent Oracle
    Type Object and OracleConnection map to make binding between Java->Oracle->Java. I could
    not get throgh meaningless run time ORA Errors. Any kind of help would be greatly
    appreciated. If you know the answer please
    post it or e-mail [email protected]
    null

    You don't say which version of the database you are on. There's an interesting looking article on OTN on handling CLOBs in JDBC in 10g. It may well be useful for earlier versions too (but no guarantees).
    Cheers, APC

  • How to Compare two Dates in java

    How to Compare two Date Field after getting the values from jTextField1.getText() and jTextField2.getText().

    Date d1=DateFormat.getDateInstance().parse(yourstring1);
    same for d2
    d1.compareTo(d2);
    could be that i misrememberd the exact naems of some functions or mixed up something in the equence of d1=

  • How to blur two objects in one scene in CS4

    I'm going a bit crazy over this.  I tried coping the video track, into track 5 and put a matte track in track 6.  I got this to work once, but when I view it again, the two blurred out objects are no longer blurred.
    I had followed this:
    http://www.wrigleyvideo.com/videotutorial/tutdes_ppro2_smoothface.htm
    But cracked up the blur a ton more.
    Is there another way to blur out two objects in a video?  I need something that will STAY.  Thanks!

    The way effects are stacked is also important.
    First Fast Blur then Track Matte.

  • How to communicate (transfer object instance) between to java vm?

    Hello, All
    If possible to transfer object instance straight between two java vm?

    It is possible to copy an object instance from one java application to another. Define it as serializable, and pass it as a parameter to an RMI call.

  • How to get stylesheet object from JAVA RESOURCE stored in DB

    Hi,
    I stored a xslt file in the database and have a JAVA RESOURCE file now. How can i get a stylesheet object from this resource file?
    I took the following class to get an impression how to get the contents of the resource but -although the name of the resource was spelled correctly- i got a file not found exception.
    Whats wrong?
    public class PrintRessource {
    public static void print (String p_ressource){
    try {
    Class c = PrintRessource.class;
    System.out.println(c.toString());
    InputStream file = c.getResourceAsStream(p_ressource);
    if (file == null)
    throw new FileNotFoundException("XSLT file not in DB");
    byte[] buffer = new byte[4096];
    int bytes_read;
    while ((bytes_read = file.read(buffer)) != -1)
    System.out.println(new String(buffer, 0 , buffer.length));
    catch (Exception exp) {
    System.out.println(exp);
    Thanks

    The code works as is. I just forgot to add the slash in front of the Resource file name.

  • How to connect two object selectors.

    Hi,
    I try to use an object selector as selection for an following object selector in CAF CORE.
    What I want:
    I choose an employee from the first object selector and click on a button "Show all flights". Now the second selector opens and all flights of these employee are shown.
    Is there a tutorial for questions like this? Or could anybody answer my question?
    Thanks and best regards
    Martin

    It's really two diffirent things.
    But you can use ObjectEditor pattern with relationship tab which can display flights for certain employee. So, you select some employee from object selector then  configured object editor is opened and you go to Relation tab of this object editor and see all the flights.
    Check the http://help.sap.com/saphelp_nw04s/helpdata/en/51/4c229fdf96f947847403afc657419b/content.htm
    Aliaksei

  • How to swap two numbers in java

    i have an idea in c but i don't know in java..somenoe like to share their idea i appreciate a lot...
    here is a sample code in c...hope u can help me in java.....thanks a lot ....
    #include<stdio.h>
    void swap(int x, int y)
    int temp;
    temp=x;
    x=y;
    y=temp;
      void main(void)
        int x=10,y=20;
          clrscr();
    printf("Before swap:x=%d,y-%d", x,y);
        swap(x,y);
    printf("\n After swap:x=%d,y=%d",x,y);
       getch();
    #include<stdio.h>
    void swap(int* x, int* y)
    int temp;
    temp=*x;
    *x=*y;
    *y=temp;
    void main(void)
    int x=10,y=20;
    clrscr();
    printf("Before swap:x=%d,y-%d", x,y);
    swap(&x,&y);
    printf("\n After swap:x=%d,y=%d",x,y);
    getch();
    }My aim of this program is to make one java file and 2 class files in java and display the output . The first output would be the number before swapping and the number after swapping.....

    There are several ways to achieve the results. You can use an array or a custom "Swaper" class to swap two values. Here is an example using generics for better code reuse.
    public class Swapper<T> {
       private T first;
       private T second;
       public Swapper(T first, T second) {
          this.first = first;
          this.second = second;
       public void swap() {
          T temp = first;
          first = second;
          second = temp;
       public <T> Swapper<T> swap(T first, T second) {
          return new Swapper<T>(second, first);
       public T getFirst() {return first;}
       public T getSecond() {return second;}
       private static void swap(int[] num) {
          if (num.length != 2) {
             throw new IllegalArgumentException("num array must be of length 2");
          int temp = num[0];
          num[0] = num[1];
          num[1] = temp;
       public static void main(String[] args) {
          // method 1: use array
          int[] num = {1, 2};
          System.out.printf("Before swap:first=%d,second=%d\n", num[0], num[1]);
          Swapper.swap(num);
          System.out.printf("After swap:first=%d,second=%d\n", num[0], num[1]);
          // method 2: use a custom "Swapper" class
          Swapper<Integer> swapper = new Swapper<Integer>(3, 4);
          System.out.printf("Before swap:first=%d,second=%d\n", swapper.getFirst(), swapper.getSecond());
          swapper.swap();
          System.out.printf("After swap:first=%d,second=%d\n", swapper.getFirst(), swapper.getSecond());
          // method 2: using another data type
          Swapper<String> stringSwapper = new Swapper<String>("C#", "Java");
          System.out.printf("Before swap:first=%s,second=%s\n", stringSwapper.getFirst(), stringSwapper.getSecond());
          stringSwapper.swap();
          System.out.printf("After swap:first=%s,second=%s\n", stringSwapper.getFirst(), stringSwapper.getSecond());
          /*    --- OUTPUT ---
           * Before swap:first=1,second=2
           * After swap:first=2,second=1
           * Before swap:first=3,second=4
           * After swap:first=4,second=3
           * Before swap:first=C#,second=Java
           * After swap:first=Java,second=C#
    }

Maybe you are looking for

  • Weblogic 10.3 standalone/Jeveloper 11.1.1.3 nonfunctional

    I have tried deploying several applications from very simple to complex. I have not gotten any one to work. All the applications work fine in the integrated environment. when deploying to the "production" environment - they all fail. None of the EJBs

  • Best IDE for developing Applets,Servlets,JSP

    Hi, I'm looking for a little bit of advise. I have been developing prototypes using Apache Tomcat. Now I need to go into a full development phase, and I need an IDE to help speedup my work, especially when it comes to debugging applets and servlets.

  • Trial downloading issues

    The download assistant for Illustrator free trial is not working, I have tried many times to download the file and already tried running as administrator and saving the file in different areas on the computer - still no luck! I tried then to download

  • Conditional Join - Specific Column Select

    hi I just receive a request from Finance Team to retrieve customer address from Account, Agent and Customer table. here is the requirement 1. when the customer is direct call in, use customer number from account table to get the address form customer

  • My ipod is not seen under portables in winamp....

    I DONT USE ITUNES BECAUSE IT DOES NOT OPEN ON MY PC....does anyone know how i can solve this issue???