Vector and my object??

hi all,
I am reading a binary file, then creating the object and adding that object in my vector. How can i get it back according to its id? let is say i added all the customers read from file and now i want to get customer 3?
int thisId=dis.readInt();
String thisName=dis.readUTF();
double thisBalance=dis.readDouble();
Customer cus=new Customer(thisName,thisId,thisBalance);
cusList.add(cus);
abdul

Best possible way is to use Hashtable and put customerid as key and Customer object
as value.
Modify your code with,
Customer cus=new Customer(thisName,thisId,thisBalance);
some-hashtable-object.put(thisId,cus);
now if you want to take particular Customer
use
Customer c = (Customer)some-hashtable-object.get(any customerid);
Now if you don't want to use Hashtable and continue with Vector then you have to iterate the,
Vector and whether object has id 3 .
like
for(int i=0;i<Vectorobject.size();i++){
Customer c = (Customer) Vectorobject.get(i);
id = c.getCustomerId() // or any method you have to get id;
// check it....
But i think Hashtable is the better way to use here.
I think you understand what i want to say .
Tarak.

Similar Messages

  • Photoshop Vectors and Smart Objects Create Blurring

    I have been supplied a Photoshop document that has Illustrator Vector files that have been placed in the PSD as Smart objects.
    When I bring the PSD into InDesign and print it, all the PSD artwork is blurry.
    How can I get the PSD file to print from InDesign at high quality.
    The PSD file is at 300 dpi. I have tried bringing it into InDesign as PSD, TIFF, EPS & PDF, but it's the same issue every time.

    Here is your screenshots

  • I created a vector and added objects, but the vector is empty

    I created an object called a facility, it accepts 2 strings in the creator but stores the data as a string and a float. as you can see from the code below, i have tried to create a vector object to contain facilitys and named it entries. when i add objects to this vector, the vectors size does not change, and i cannot access elements of it via their index. but when i print the vector out i can see the elements? what is going on here. i am very confused. ps, if it helps i havent worked with vectors much before.
    FacilitysTest.java
    import java.util.*;
    public class FacilitysTest {
         public static void main (String [] args) {
         Facilitys entries = new Facilitys();
         entries.add("Stage","3.56");
         entries.add("kitchen","5.00");
         entries.add("heating","2");
    //     System.out.println(entries.firstElement() );
         System.out.println("printing out entries");
         System.out.println(entries);
         System.out.println();
         System.out.println("There are "+entries.size()+" entries");
         System.out.println();
         System.out.println("modifying entry 2");
         entries.setElementAt(new Facility("lighting","1.34"), 2);
         System.out.println(entries);
         System.out.println();
         System.out.println("deleting entry 1");
         entries.remove(1);
         System.out.println(entries);
    }the following is what happens when i run this code.
    the number (0,1,2) is taken from a unique number assigned to the facility and is not anything to do with the facilitys position in the vector.
    printing out entries
    Facility number: 0, Name: Stage , Cost/Hour: 3.56
    Facility number: 1, Name: kitchen , Cost/Hour: 5.0
    Facility number: 2, Name: heating , Cost/Hour: 2.0
    There are 0 entries
    modifying entry 2
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2 >= 0
    at java.util.Vector.setElementAt(Vector.java:489)
    at FacilitysTest.main(FacilitysTest.java:17)
    Press any key to continue . . .
    Facilitys.java
    import java.util.*;
    public class Facilitys extends Vector {
         private Vector entries;
         public Facilitys( ) {
                 entries = new Vector();
        public void add( String name, String price ) {
             entries.add((new Facility( name, price) ));
        public Facility get(int index) {
              return ((Facility)entries.get(index));
         public float total() {
              float total = 0;
              for (int i = 0; i<entries.size();i++) {
                   total = total + ( (Facility)entries.get(i) ).getPricePerHour();
              return total;
        public String toString( ) {
            StringBuffer temp = new StringBuffer();
            for (int i = 0; i < entries.size(); ++i) {
                temp.append( entries.get(i).toString() + "\n" );
            return temp.toString();
    }

    are you reffering to where i have public class
    Facilitys extends Vector {
         private Vector entries;
         public Facilitys( ) {
                 entries = new Vector();
    That's correct. That's your problem.
    i added the extends Vector, because without it i got
    the following errors
    C:\Documents and Settings\george\My
    Documents\University\JavaCode\CM0112\FacilitysTest.jav
    a:14: cannot find symbol
    symbol : method size()
    location: class Facilitys
    System.out.println("There are "+entries.size()+"
    " entries");That's because you haven't implemented a size method in your class.
    ^
    C:\Documents and Settings\george\My
    Documents\University\JavaCode\CM0112\FacilitysTest.jav
    a:17: cannot find symbol
    symbol : method setElementAt(Facility,int)
    location: class Facilitys
    entries.setElementAt(new
    w Facility("lighting","1.34"), 2);That's because you haven't implemented setElementAt in your class.
    C:\Documents and Settings\george\My
    Documents\University\JavaCode\CM0112\FacilitysTest.jav
    a:21: cannot find symbol
    symbol : method remove(int)
    location: class Facilitys
         entries.remove(1);
    ^That's because you haven't implemented remove in your class.
    /Kaj

  • Vector and session object...

    Hi, I have a JSP that retrieves a resultset with 3000+ rows. I use that resultset to create a summary page of grouped data, so the resulting page is only a few lines. Each group is a link that can be double clicked to call a JSP that will display the detail line items.
    From a developers viewpoint, this is how I'm doing it: On the first JSP, as I scan through the resultset creating the summary line items I add the detail data to a vector. After I'm done processing the resultset I add the vector to the session object. When the hyperlink on the first JSP is activated I call a second JSP that retreives the vector from the session object and display the results.
    Is that a good idea or a bad idea? It seems to work ok, but I'm thinking it might be alot of data to be storing on a session object especially when you consider the number of users that could be on. Is there a way to compress the vector when I add it to the session object? Is there a better way to do this? Unfortunately, I can't re-retrieve the data because the SQL takes too long. Thanks!

    Sure you could compress it... you could use the classes in java.util.zip, and use an ObjectOutputStream plus a ZipOutputStream plus a ByteArrayOutputStream (I think), using zip compression to convert your Vector into an array of bytes, and then do the reverse when you needed the data uncompressed. Chances are that would compress your data by about 80 or 90%.
    Here you would be making the classic tradeoff between memory usage and processing time; I wouldn't do this compression thing until it was clear that it was necessary, though.

  • Problem when adding java objects in a vector and passing thru web service

    Hi! I'm getting this error when I try to add a java object I created into a vector and passing it through a web service: java.lang.IllegalArgumentException: No Serializer found to serialize a 'testObj' using encoding style 'http://schemas.xmlsoap.org/soap/encoding/'
    This does not happen when I simply add strings or Integer objects into the vector. What am I missing?
    Thanks.

    just chek this
    http://forum.java.sun.com/thread.jspa?threadID=501189&messageID=2370914
    Edited by: garava on Jul 16, 2008 1:13 PM.
    It would be great if you could paste the wsdl part for that vector and just have a look for the complex typr cntent
    like for HashMap we have the following mapping
    <complexType name="HashMap">
      <sequence>
        <element name="item" minOccurs="0" maxOccurs="unbounded">
          <complexType>
            <sequence>
              <element name="key" type="anyType" />
              <element name="value" type="anyType" />
            </sequence>
          </complexType>
        </element>
      </sequence>
    </complexType>Since in Value it should again contain a mapping for the Object which you are trying to pass then only an appropriate serializer and deserilaizer would get generated. Hope this answers your query. For refernece
    http://www.theserverside.com/tt/articles/article.tss?l=Systinet-web-services-part-2
    [http://www.theserverside.com/tt/articles/article.tss?l=Systinet-web-services-part-2|For refernce tutorial]
    Thanks,
    Avadhoot Sawant.
    Edited by: garava on Jul 16, 2008 1:16 PM

  • Please help, 2D Array of Vectors and Incompatible types :(

    I have a 2D array of vectors called nodeLocations but when I try and access the vector inside I get a compile error.
    My code is something like this:
    nodeLocations[j].addElement(noArc)
    My editor picks up that its a Vector and shows me addElement as an acceptable entry to put after the "." yet the compiler says:
    "addElement(java.lang.Object) in java.util.Vector cannot be applied to (int)"
    Can someone please help?
    Thank you in advance.
    also a related problem:
    I get inconvertible types (says int required) when I try and get an element from a vector stored in a 2D Array. I know that it comes out as an object and so should be cast but it does not seem to work. My code is as follows:
    else if (((int)(nodeLocations[nodeNumber][adjNodeNumber].elementAt(0))) != distance)
    I would appreciate any help anyone can give.
    Similar errors to the above two happen when
    I try a push with a Stack in a vector.
    I try to get something out of the stack inside the vector.

    The Vector class's addElement() method requires an Object parameter. It appears that you're trying to add an int to the Vector. You'll need to create an Integer object and place that into the vector (see sample below) or use the pre-release version of JDK 1.5 which provides autoboxing capabilities.
    int z = 5;
    Integer x = new Integer(z);
    nodeLocations[j].addElement(x);

  • Vector and Jtree 4Duke

    hi
    i am having poblem with my jtree as i am not able to show the object in my vector as a different node
    {each object is node of my tree}
    unfortunately they all appear flat in the root, and in sequence{as one node} ??
    i have done everything but still no answer??
    thanks in advance for any solution
    public class Gui extends JFrame
    {  Vector root = new Vector();
    public JTree theTree ;
    public SERGui( )
    System.out.println(root.size());//root vector is empty
    roott = new DefaultMutableTreeNode (root);
    model = new DefaultTreeModel (roott) ;
    theTree = new JTree (model);      
    public Vector addOne(String newString)
    if (!root.contains(getQuery))
               root.add(newString);
    model.reload();
    // //updateTree(); i also try this method whiich does not work
    return root;
    public void updateTree(){
    DefaultMutableTreeNode v = (DefaultMutableTreeNode)theTree.getModel().getRoot();
    for(int i=0;i<root.size();i++)
                   DefaultMutableTreeNode node = (DefaultMutableTreeNode)root.elementAt(i);
                   roott.add(node);
    ((DefaultTreeModel)theTree.getModel()).reload(v);
    //DefaultMutableTreeNode node = null;
    print_vector(root);
      //root.clear();
         }and my other class
    where i call this methos is as follow
    Class Search()
    public void countWord(String newString)
    {Gui.addOne(newString);
    }}

    You are passing a Vector into the constructor of the DefaultMutableTreeNode to create the root of your tree. The DefaultMutableTreeNode will use this object's string representation (by calling toString on whatever object you pass in its constructor) as the name of the tree node. So basically you will see the entire contents of the vector as the name of your root node.
    You need to traverse your vector, and use each element to create a DefaultMutableTreeNode and add it to your root node.
    here is the modified code
    public class Gui extends JFrame {
    private Vector rootVector = new Vector();
    private JTree theTree;
    private DefaultMutableTreeNode rootNode;
    private DefaultTreeModel model;
    public Gui() {
    System.out.println(rootVector.size());
    //root vector is empty
    rootNode = new DefaultMutableTreeNode("Root");
    model = new DefaultTreeModel(rootNode);
    theTree = new JTree(model);
    public Vector addOne(String newString) {
    if (!rootVector.contains(newString)) {
    rootVector.add(newString);
    updateTree();
    return rootVector;
    public void updateTree() {
    rootNode.removeAllChildren();
    for (int i = 0; i < rootVector.size(); i++) {
    DefaultMutableTreeNode node = new DefaultMutableTreeNode(
    rootVector.elementAt(i));
    rootNode.add(node);
    ((DefaultTreeModel) theTree.getModel()).reload(rootNode);
    Hemant Mahidhara

  • Newbie question about using vectors and arrays

    I'm fairly new to JME development and java in general. I need some help in regards to Vectors and 1 dimensional arrays. I'm developing a blackberry midlet and am saving the queried info i pull back from my server side application with each record saved into the array and subsequently each array saved as an element in the vector, thereby creating a 2D "array".
    However I'm having a problem accessing the elements in the array. Here is a sample of what I mean and where I get stuck:
    Vector _dataTable = new Vector(1, 1);
    String[] r1 = {"a", "b", "c", "d"};
    String[] r2 = {"1", "2", "3", "4"};
    _dataTable.addElement(r1);
    _dataTable.addElement(r2);
    Object temp = _dataTable.elementAt(0); //Save the element as an new object for useNow how do I access the particular indexes of the element of the temp object? Do i need to caste it to an array? Is there another more efficient/easier way I should be storing my data? Any help would be great!
    Edited by: Sotnem2k1 on Apr 1, 2008 7:50 AM
    Edited by: Sotnem2k1 on Apr 1, 2008 7:51 AM

    Thanks for the feedback newark. I have this scenario below:
    // Class for my 1D array
    public class OneRecord {
        private String[] elementData = new String[4];
        public OneRecord() {   
            elementData[0] = null;
            elementData[1] = null;
            elementData[2] = null;
            elementData[3] = null;
        public OneRecord(String v1, String v2, String v3, String v4) {   
            elementData[0] = v1;
            elementData[1] = v2;
            elementData[2] = v3;
            elementData[3] = v4;
        public void setElement(int index, String Data) {
            elementData[index] = Data;
        public String getElement(int index) {
            return elementData[index];
    } Then in my main app I have:
    Vector _dataTable = new Vector(1, 1);
    OneRecord currRecord = new OneRecord("a", "b", "c", "d");
    _dataTable.addElement(currRecord);
    OneRecord temp = (OneRecord)_dataTable.elementAt(1);
    System.out.println(temp.getElement(0)); Are there more efficient data structures out there to save queried data from a server side app? Like I said, i'm still trying to learn the most efficient techniques of coding...esp for the Blackberry. Any suggestions would be great!

  • Why can't I add an Object[] to a Vector ? super Object[] ?

    I don't understand why javac rejects these two statements:
        Vector<? super Object[]> v= new Vector<Object[]>();
        v.add(new Object[0]);cannot find symbol
    symbol : method add(java.lang.Object[])
    location: class java.util.Vector<capture of ? super java.lang.Object[]>
    v.add(new Object[0]);
    ^
    The type of v can only be one of these 4:
    Vector<Object[]>, Vector<Object>, Vector<Serializable>, Vector<Cloneable>.
    Therefore, I should always be allowed to add an Object[] to it, right?
    The following example is very similar, but this one is accepted by javac.
        Vector<? super Number> v= new Vector<Number>();
        v.add(42);I didn't find a relevant difference to the first example, nor something in JLS3 that would forbid it. Is this a javac bug?

    There is a difference between legal and practical. Practical is a matter of opinion. I thought I should try the combinations to see which make sense.
    I don't find it intuative that list.add(list.get(0)) should fail to compile.
    While the definitions have a logic of their own, some are very hard to put it into english exactly what they really mean. This means finding a practical purpose for them even harder.
    For example List<? super Object>
    add(x) is legal for non-arrays
    method(list) is illegal for method(List<Object>) but is legal for method(List<? super Object[]>)
    public class A {
        public static void foo(List<? super Object[]> l) {    }
        public static void foo2(List<Object[]> l) {    }
        public static void foo3(List<? extends Object[]> l) {    }
        public static void bar(List<? super Object> l) {    }
        public static void bar2(List<Object> l) {    }
        public static void bar3(List<? extends Object> l) {    }
        public static void bar4(List<?> l) {    }
        public static void main(String[] args) {
            {   // can be { Object, Object[] }
                List<? super Object[]> l = new ArrayList<Object[]>();
                l.add(l.get(0));  // illegal
                l.add((Object) null);  // illegal
                l.add((Integer) null);  // illegal
                l.add((Object []) null); // illegal
                l.add((Integer []) null); // illegal
                l.add((Integer [][]) null); // illegal
                foo(l); // List<? super Object[]> - legal
                foo2(l); // List<Object[]> - illegal
                foo3(l); // List<? extends Object[]> - illegal
                bar(l); // List<? super Object> - illegal
                bar2(l); // List<Object> - illegal
                bar3(l); // List<? extends Object> - legal
                bar4(l); // List<?> - legal
            {   // can be Object[] or (? extends Object)[]
                List<Object[]> l = new ArrayList<Object[]>();
                l.add(l.get(0));  // legal
                l.add((Object) null);  // illegal
                l.add((Integer) null);  // illegal
                l.add((Object []) null); // legal
                l.add((Integer []) null); // legal
                l.add((Integer [][]) null); // legal
                foo(l); // List<? super Object[]> - legal
                foo2(l); // List<Object[]> - legal
                foo3(l); // List<? extends Object[]> - legal
                bar(l); // List<? super Object> - illegal
                bar2(l); // List<Object> - illegal
                bar3(l); // List<? extends Object> - legal
                bar4(l); // List<?> - legal
            {   // Only allows wildcards, Object is illegal.
                List<? extends Object[]> l = new ArrayList<Object[]>();
                l.add(l.get(0));  // illegal
                l.add((Object) null);  // illegal
                l.add((Integer) null);  // illegal
                l.add((Object []) null); // illegal
                l.add((Integer []) null); // illegal
                l.add((Integer [][]) null); // illegal
                foo(l); // List<? super Object[]> - illegal
                foo2(l); // List<Object[]> - illegal
                foo3(l); // List<? extends Object[]> - legal
                bar(l); // List<? super Object> - illegal
                bar2(l); // List<Object> - illegal
                bar3(l); // List<? extends Object> - legal
                bar4(l); // List<?> - legal
            {   // can add non-arrays but can only match ? super Object, ? super Object[], or ? extends Object, but not Object 
                List<? super Object> l = new ArrayList<Object>();
                l.add(l.get(0));  // legal
                l.add((Object) null);  // legal
                l.add((Integer) null);  // legal
                l.add((Object []) null); // illegal
                l.add((Integer []) null); // illegal
                l.add((Integer [][]) null); // illegal
                foo(l); // legal
                foo2(l); // illegal
                foo3(l); // illegal
                bar(l); // legal
                bar2(l); // illegal
                bar3(l); // legal
                bar4(l); // legal
            {   // can add array but cannot call a method which expects an array. 100% !
                List<Object> l = new ArrayList<Object>();
                l.get(0).toString();
                l.add(l.get(0));  // legal
                l.add((Object) null);  // legal
                l.add((Integer) null);  // legal
                l.add((Object []) null); // legal
                l.add((Integer []) null); // legal
                l.add((Integer [][]) null); // legal
                foo(l); // legal
                foo2(l); // illegal
                foo3(l); // illegal
                bar(l); // legal
                bar2(l); // legal
                bar3(l); // legal
                bar4(l); // legal
            {   // cannot add any type but can match ? or ? extends Object.
                List<? extends Object> l = new ArrayList<Object>();
                l.add(l.get(0));  // illegal
                l.add((Object) null);  // illegal
                l.add((Integer) null);  // illegal
                l.add((Object []) null); // illegal
                l.add((Integer []) null); // illegal
                l.add((Integer [][]) null); // illegal
                foo(l); // List<? super Object[]> - illegal
                foo2(l); // List<Object[]> - illegal
                foo3(l); // List<? extends Object[]> - illegal
                bar(l); // List<? super Object> - illegal
                bar2(l); // List<Object> - illegal
                bar3(l); // List<? extends Object> - legal
                bar4(l); // List<?> - legal
            {   // same as ? extends Object.
                List<?> l = new ArrayList<Object>();
                l.add(l.get(0));  // illegal
                l.add((Object) null);  // illegal
                l.add((Integer) null);  // illegal
                l.add((Object []) null); // illegal
                l.add((Integer []) null); // illegal
                l.add((Integer [][]) null); // illegal
                foo(l); // List<? super Object[]> - illegal
                foo2(l); // List<Object[]> - illegal
                foo3(l); // List<? extends Object[]> - illegal
                bar(l); // List<? super Object> - illegal
                bar2(l); // List<Object> - illegal
                bar3(l); // List<? extends Object> - legal
                bar4(l); // List<?> - legal
    }

  • Photoshop CS6 Scaling issues: Vector/Raster smart objects

    My team and I have noticed some strange issues when affecting the overall interpolation of a .psd via scaling, cropping, or canvas resize.
    Test:
    Original .psd is even x even overall pixel dimensions.
    Original vector and raster smart object assets are all proportionally scaled with width x height percentages equal.
    Preferences: "Snap vector tools and transforms to pixel grid" is turned off
    Resize .psd via Image > Image Size palette.
    Scale styles, constrain proportions selected.
    Every interpolation style tested.
    Resize the .psd to 50%
    Result: All smart objects (both types) no longer are proportionately scaled. Usually off by a minor amount under 1/10th of a percent.
    Some objects' center point shift a half pixel to the right or left.
    This also occurs if we use the crop tool or resize the canvas.
    Is this a known bug and if so, is there:
    1) any setting to truly lock proportions?
    2) any resolution being pursued currently?
    Though the shift and the disproproptions seem minor, the overall quality of items such as icons, hairlines, and other things that should be more crisp become far more degraded in CS6 vs CS5.
    We have over 100 users and need to evaluate if we should drop back down to CS5, where we weren't having any of these issues, as our work demands a lot of precision, so you can see why this is worrisome.
    Thanks!

    I'm not going to say anything about the abysmal rendering of Vector Smart Objects in CS6 because it'll be beating a dead horse but I can explain the issues you see with measurements after scaling.
    The slightly disproportionate scaling and half-pixel shift of the centre is unavoidable when it happens because the resulting Smart Object/Vector Smart Object must measure an integer number of pixels in height and width and be perfectly aligned to the document pixel grid. That's true in CS5 and CS6.
    Say a SO/VSO originally measures 102 x 103 pixels and you scale it by 50%. The Options bar may say the result is 51 x 51.5 px but the result will really be 51 x 52 px, and therefore the new height will really be 50.49% of the old height.
    The original SO/VSO is an even number of pixels wide and an odd number of pixels high, therefore its centre will be halfway down a pixel. The 50%-scaled SO/VSO is an odd number of pixels wide and an even number of pixels high, therefore its centre will be halfway across a pixel.

  • Searching a Vector of SimpleDateFormat objects

    Hi everyone,
    I have implemented a vector of vector structure. Each vector contains a list of objects which have been parserd from a log file. I need to write a method which searches one of the inner vectors containing SimpleDateFormat Objects. Two Dates will be entered by the user and the positons of the date objects found within these two dates needs to be returned. If anyone could help that would be great.
    Jonny

    Hi everyone,
    I have implemented a vector of vector structure. Each
    vector contains a list of objects which have been
    parserd from a log file. I need to write a method
    which searches one of the inner vectors containing
    SimpleDateFormat Objects. Two Dates will be entered
    by the user and the positons of the date objects found
    within these two dates needs to be returned. If
    anyone could help that would be great.
    JonnyWhat? Is it me, or is this a little confused?
    Do the inner vectors really contain instances of java.text.SimpleDateFormat?
    Could you re-state the problem with an example?

  • Easy way to clone a Vector and its Content?

    I have a Vector containing String Arrays. I would like to clone the vector an all it's content.
    Just cloning the vector doesn't work, because just the vector gets cloned whereas the references to the StringArrays in the vector stay the same.
    So i guess i have to clone all the StringArrays too? This would be a very "expensive" process, so i'd like to ask first, if there is another methode to clone a vector and it's content?
    Thanks for your help!

    No. Clone gives you a shallow copy. What you want is a deep copy. However, since Strings are immutable, you only need to deeply copy the string arrays, not the strings themselves. If you were working with mutable objects, this would not be the case and you would need to copy the items in the array as well as the array itself.

  • How can I loop through a Vector and compare

    I'm working on a school project that is a quiz server. Instructors could telnet into the app and create quizes and then users can take them. I have it so it can set up new quizes so far. Right now I'm working on it so the user can choose a quiz and take the test. Since it requires proper user handling I have it so I display the quiz ID and quiz Name. The user would need to enter the quiz ID to take it. I have it that as it displays the ID's it enters them into a Vector. Then I do a loop through all elements until I get one that equals the user selection. I'm having problems with it though. Here's some code:
    do
    quizCheck = false;
    for (int i=0;quizReference.size();i++)
    if (selectionInt==quizReference.elementAt(i))
    quizCheck=true;
    }while (quizCheck==false);
    It's giving me a Error #300:method==(int,java,lang.Object)not found in class testproject.TestProject on the if line. Is there a way to handle this scenario. Also is there a better way?

    Hi,
    elementAt(...) returns an Object - of what type is your selectionInt? - guess, it is a primitve int value, not an Object.
    You can find it easier - say, you have Integer values in that Vector - and selectionInt is an int value - now you can find it using
    int p = quizReference.indexOf(new Integer(selectionInt));
    p is either -1 (if not found) or the index of the first found element, with the same int value as selectionInt.
    Hope, this helps
    greetings Marsian

  • Cannot send and read objects through sockets

    I have these 4 classes to send objects through sockets. Message and Respond classes are just for
    trials. I use their objects to send &#305;ver the network. I do not get any compile time error or runtime error but
    the code just does not send the objects. I used object input and output streams to send and read objects
    in server (SOTServer) and in the client (SOTC) classes. When I execevute the server and client I can see
    that the clients can connect to the server but they cannot send any objects allthough I wrote them inside the main method of client class. This code stops in the run() method but I could not find out why it
    does do that. Run the program by creating 4 four classes.
    Message.java
    Respond.java
    SOTC.java
    SOTServer.java
    Then execute server and then one or more clients to see what is going on.
    Any ideas will be appreciated
    thanks.
    ASAP pls
    //***********************************Message class**********************
    import java.io.Serializable;
    public class Message implements Serializable
    private String chat;
    private int client;
    public Message(String s,int c)
    client=c;
    chat=s;
    public Message()
    client=0;
    chat="aaaaa";
    public int getClient()
    return client;
    public String getChat()
    return chat;
    //*******************************respond class*****************************
    import java.io.Serializable;
    public class Respond implements Serializable
    private int toClient;
    private String s;
    public Respond()
    public Respond(String s)
    this.s=s;
    public int gettoClient()
    return toClient;
    public String getMessage()
    return s;
    //***********************************SOTServer*********************
    import java.io.*;
    import java.net.*;
    import java.util.Vector;
    //private class
    class ClientWorker extends Thread
    private Socket client;
    private ObjectInputStream objectinputstream;
    private ObjectOutputStream objectoutputstream;
    private SOTServer server;
    ClientWorker(Socket socket, SOTServer ser)
    client = socket;
    server = ser;
    System.out.println ("new client connected");
    try
    objectinputstream=new ObjectInputStream(client.getInputStream());
    objectoutputstream=new ObjectOutputStream(client.getOutputStream());
    catch(Exception e){}
    public void sendToClient(Respond s)
    try
    objectoutputstream.writeObject(s);
    objectoutputstream.flush();
    catch(IOException e)
    e.printStackTrace();
    public void run()
    do
    Message fromClient;
    try
    fromClient =(Message) objectinputstream.readObject();
    System.out.println (fromClient.getChat());
    Respond r=new Respond();
    server.sendMessageToAllClients(r);
    System.out.println ("send all completed");
    catch(ClassNotFoundException e){e.printStackTrace();}
    catch(IOException ioexception1)
    ioexception1.printStackTrace();
    break;
    Respond k=new Respond();
    sendToClient(k);
    }while(true);
    public class SOTServer
    ServerSocket server;
    Vector clients;
    public static void main(String args[]) throws IOException
    SOTServer sotserver = new SOTServer();
    sotserver.listenSocket();
    SOTServer()
    clients = new Vector();
    System.out.println ("Server created");
    public void sendMessageToAllClients(Respond str)
    System.out.println ("sendToallclient");
    ClientWorker client;
    for (int i = 0; i < clients.size(); i++)
    client = (ClientWorker) (clients.elementAt(i));
    client.sendToClient(str);
    public void listenSocket()
    try
    System.out.println ("listening socket");
    server = new ServerSocket(4444, 6);
    catch(IOException ioexception)
    ioexception.printStackTrace();
    do
    try
    ClientWorker clientworker=new ClientWorker(server.accept(), this);
    clients.add(clientworker);
    clientworker.start();
    catch(IOException ioexception1)
    ioexception1.printStackTrace();
    while(true);
    protected void finalize()
    try
    server.close();
    catch(IOException ioexception)
    ioexception.printStackTrace();
    //*************************SOTC***(client class)*********************
    import java.io.*;
    import java.net.Socket;
    import java.net.UnknownHostException;
    class SOTC implements Runnable
    private Socket socket;
    private ObjectOutputStream output;
    private ObjectInputStream input;
    public void start()
    try
    socket= new Socket("127.0.0.1",4444);
    input= new ObjectInputStream(socket.getInputStream());
    output= new ObjectOutputStream(socket.getOutputStream());
    catch(IOException e){e.printStackTrace();}
    Thread outputThread= new Thread(this);
    outputThread.start();
    public void run()
    try
    do
    Message m=new Message("sadfsa",0);
    output.writeObject(m);
    Respond fromServer=null;
    fromServer=(Respond)input.readObject();
    }while(true);
    catch(NullPointerException e){run();}
    catch(Exception e){e.printStackTrace();}
    public SOTC()
    start();
    public void sendMessage(Message re)
    try
    Message k=new Message("sdasd",0);
    output.writeObject(k);
    output.flush();
    catch(Exception ioexception)
    ioexception.printStackTrace();
    System.exit(-1);
    public static void main(String args[])
    SOTC sotclient = new SOTC();
    try
    System.out.println("client obje sonrasi main");
    Message re=new Message("client &#305;m ben mesaj bu da iste",0);
    sotclient.sendMessage(re);
    System.out.println ("client gonderdi mesaji");
    catch(Exception e) {e.printStackTrace();}

    ObjectStreams send a few bytes at construct time. The OutputStream writes a header and the InputStram reads them. The InputStream constrcutor will not return until oit reads that header. Your code is probably hanging in the InputStream constrcutor. (try and verify that by getting a thread dump)
    If that is your problem, tolution is easy, construct the OutputStreams first.

  • Vector and PNG jagged lines

    Hi!
    I've created a vectorized logo using CorelDraw X7. As my workflow consists of Adobe products, as Lightroom, Photoshop and InDesign, I though it would be convenient to integrate Illustrator in my workflow for better file handling. Then I've faced my first problem: export from Corel to Illustrator. As Corel allowed me to export in .AI file format, that was the best quick solution. But when I opened the file inside Illustrator, it wasn't good looking, and I realized it needed some adjustments. To be honest, the issue was specifically with a line stroke within my logo, noticeably jagged. I've already checked if I was in Pixel Preview Mode, as well as the anti-aliasing options, pixel grid alignment and the document resolution [I've done a extensive search about the issue before posting here, but haven't find anything really helpful]. I tried to redesign the logo using Illustrator, but the ******* line keeps frustrating me.
    I know that I'm working with vectors and that shouldn't be happening, even taking into consideration that the monitor inevitably shows images in pixels. That said, if I zoom in a lot, I can see perfect lines, but zoomed at 100 or 200%, the jagged lines are there. I though that it was just a preview issue from Illustrator that wouldn't affect the output file, so I exported it in PNG, which is the output file I mostly use in those cases, but the issue remained. The line stroke I'm talking about is a fine line with variable width at both tips [wider in the middle and tapering at the ends]. This tapering is what causes the problem, creating a jagged effect from the middle section through the ends. What's curious about it is that the same line, when the original file is opened in Corel, is showed smooth and perfect, in vector lines or after PNG export.
    As it wasn't enough, ironically, if I create the same line in Photoshop and paste it into Illustrator [which recognizes it as a raster image], the output is exactly what I expected when exported to PNG [from Illustrator] and with a far better preview inside Illustrator, though still a bit jagged with 100% zoom. But as I plan to work with vector lines up to the moment of exporting files, a rasterized object wasn't part of my plans...
    I'll be very glad if someone is able to help me. I'm working on CC 2014.
    Follows a link to the open files from Corel and Illustrator. For comparison purposes, inside Illustrator file there are 3 versions of the line, being the first the original Corel vector, the middle one is the Photoshop raster, and the third is the one created inside Illustrator using elipse tool.
    Dropbox - Logo.rar
    PS.: English isn't my native language, so my apologies for some mistakes I may have commited

    Even when I create the same line using Illustrator tools? I though I'd have no problem creating a fine line with variable width.
    Here goes the print screens of what you asked me. The first one is the info of the line created on Corel; the other is the one created on Illustrator:

Maybe you are looking for

  • Install 3rd party emulator in Java ME SDK 3.0

    Hi! I have just uppgraded from the EA release to 3.0. When I had the EA release I added a number of 3rd party emulators to be able to run my midlet with the 'Run With' command. Now I can't get the emulators installed. I try Tools/Java Platform/Add Pl

  • Executable does not open dynmanically loaded vis

    I have an ATE that is in vi form and works fine in this manner. It runs tests that are chosen by the user but the tests are not subvi's with in the program, they are called dynmanically by a vi that locates, opens the vi being called and closes when

  • Calendar Server eating events with locations - 412 precondition failed

    Start off saying that we are pretty sure this was happening to us on Lion before the upgrade as well. Here is the scenario: We get an ics attachement to an email. The user opens it in Calendar - it shows up grey. They click on it, select the Calendar

  • Cannot find JavaDoc for the com.sun.msv package

    Where can I find the JavaDoc for the com.sun.msv package ?

  • Problem with image store

    when I try to transfer images from nokia 6101 phone to pc, I keep getting a visual C++ runtime error that says the program had to terminate. What is causing this error?