Vector problem

Hi to you all,
I have built a table which retrieves data from a .jsp file by making an http request. The particular request is made every 10 seconds.
The data is read in lines and the lines are stored in a vector.
i.e. the line is: 1 34 er ty 23
where id=1
The table is built by getting the vector elements (lines). The first element of each line is the "id"(int). On the second request data might have been changed in one or more lines in the .jsp file, thus the program must identify the change(s) and update only the specific line(s) according to the "id". I tried to do something but unfortunately the program reads only the first line of the .jsp file. Can u give me any hlep. Apologies if the explanation of my problem is poor.
I am including the specific part of my code.
Thanx
public void readDataLine()
          URL url;
          URLConnection connection;
          String inputLine;     
          DataInputStream inStream;
          int position = -1;
          int id=0;
          int i=0;
          String cToken;
          try
          url = new URL("http","127.0.0.1",80,"/clock.jsp");
          connection = url.openConnection();
          inStream = new DataInputStream (connection.getInputStream());
          //BufferedReader br = new BufferedReader(inStream);
          while (null != inStream.readLine())
               String st = inStream.readLine();
               System.out.println("st: " + st);
                    StringTokenizer tokenizer = new StringTokenizer(st, ";");
                    //System.out.println("The String has " + tokenizer.countTokens() + " words." );
                    while (tokenizer.hasMoreTokens())
                         cToken = tokenizer.nextToken();
                         data.addElement(cToken);
                         if (i == 0)
                              id = Integer.parseInt(cToken);
                         i++;
                    // Add the vector with the 16 elements to the vector of vectors.
                    // vLocalStore.addElement(data.clone());
                    //hold vector into memory
                    // perform the change
                    position = -1;
                    for (i=0; i<vLocalStore.size(); i++)
                         Vector v = (Vector) vLocalStore.elementAt(i);
                         if (id == ((Integer) v.firstElement()).intValue())
                              position = i;
                              break;
                    if (position == -1)
                         // this is a new element in the vector
                         vLocalStore.addElement(data.clone());
                         System.out.println("v: " + vLocalStore);
                    else
                         // this is a replacement instruction
                         vLocalStore.removeElementAt(position);
                         vLocalStore.insertElementAt(data.clone(),position);
                         //System.out.println("id: " + ((Integer) v.firstElement()).intValue());
                         System.out.println("v: " + vLocalStore);
                    // Clear all the 16 elements.
                    data.clear();
          inStream.close();
          }           // end try
          catch (IOException e)
          System.err.println("I/O Exception: " + e);
          catch (NoSuchElementException e)
          System.err.println("No such element: " + e.getMessage());
          catch (ArrayIndexOutOfBoundsException e)
               System.err.println("Exception: " + e.getMessage());
          catch (Exception e)
               System.err.println("Exception: " + e.getMessage());
     }          // end readDataLine

Actually, I doubt it reads the first line. You've written while (null != inStream.readLine())
    String st = inStream.readLine();This reads the first line, discards it, and then reads another line. What you should replace it with is String st;
while ((st = inStream.readLine()) != null)
{or, if you want to keep your scope minimal,for (String st; (st = inStream.readLine()) != null; /* do nothing*/)
{There may be other errors, but it's hard to read unformatted code. If this doesn't fix the problem, please repost the code using &#91;code] tags.

Similar Messages

  • Vector problem... Please help!

    Hi,
    I searched the forum but I could not get a correct answer for a vector problem I am facing. I have 2 SQL queries that are nested. Initially I tried to nest them but realized that when I close the connection to one query I cannot nest the other since the first query is closed ( blazix web server does not let you open open a wuery if you have not closed one query) Somebody had suggested to include the infor on a Vector and then reuse it. However I am not sure of how to do this.
    The following is what I have so far.
    <%@ page import="java.util.Vector" %>
    <%
    <blx:sqlQuery id="Buttons">
    Select      ID, Ntive, ButtonLabel ButtonLink
    From Pages
    </blx:sqlQuery>
    <% } else { %>
    <blx:sqlQuery id="Project">
    Select      ID, ProjectName, PLongName
    From Projects
    </blx:sqlQuery>
    <% } %>
    // now both of these queries are nested within each other to get the output.
    <blx:sqlExecuteQuery resultSet="rs" queryRef="Buttons">
    <%
    int ID = rs.getInt("ID");
    int Ntive = rs.getInt("Ntive");
    String ButtonLabel=rs.getString("ButtonLabel");
    String ButtonLink=rs.getString("ButtonLink");
    %>
    <% if (ID != 1){
    if (Ntive ==1) {
         Link="index.jsp?Page="+ID;
         } else {
         Link= ButtonLink;
    %>
    <LI><a href="<%=Link%">> <%=ButtonLabel%></a></LI>     
    <% if (ID==2) {%>
    // then I start the second query projects.
    <blx:sqlExecuteQuery resultSet="rs" queryRef="Project">
    </blx:sqlExecuteQuery>
    <% if (ID==3) %>// this is again from the first query
    // here i start the second query again
    //now I close the first query.
    Please help me to write a Vector withnin here and to retrieve the information to be used again on the same JSP page.
    Thanks!

    I wonder why Blazix dosnt allow multiple queries.
    Here is the logic using Vectors.
    <%@ page import="java.util.Vector" %>
    Vector IDVector = new Vector();
    Vector NtiveVector = new Vector();
    Vector ButtonLabelVector = new Vector();
    Vector ButtonLinkVector = new Vector();
    if(whatever is the codition here)
         %>
         <blx:sqlQuery id="Buttons">
              Select ID, Ntive, ButtonLabel, ButtonLink
              From Pages
         </blx:sqlQuery>
         <%
    else
         %>
         <blx:sqlQuery id="Project">
         Select ID, ProjectName, PLongName
         From Projects
         </blx:sqlQuery>
         <%
    %>
    <blx:sqlExecuteQuery resultSet="rs" queryRef="Buttons">
    <%
         IDVector.add(rs.getInt("ID"));
         NtiveVector.add(rs.getInt("Ntive"));
         ButtonLabelVector.add(rs.getString("ButtonLabel"));
         ButtonLinkVector.add(rs.getString("ButtonLink"));
    %>
    //now I close the first query.
    </blx:sqlQuery>
    <%
    for(rec=0;rec<IDVector.size();rec++)
         int ID = (int) IDVector.elementAt(rec);
         int Ntive = (int) NtiveVector.elementAt(rec);
         String ButtonLabel = (String) ButtonLabelVector.elementAt(rec);
         String ButtonLink = (String) ButtonLinkVector.elementAt(rec);
         if (ID != 1)
              if (Ntive ==1)
                   Link="index.jsp?Page="+ID;
              else
                   Link= ButtonLink;
              %>
              <LI><a href="<%=Link%">> <%=ButtonLabel%></a></LI>
              <%
              if (ID==2)
                   %>
                   // then I start the second query projects.
                   <blx:sqlExecuteQuery resultSet="rs" queryRef="Project">
                   </blx:sqlExecuteQuery>
                   <%
              if (ID==3)
                   %>
                   // this is again from the first query
                   // here i start the second query again
                   <%
    %>
    Hope it helps.
    -Mak

  • Vector problem after copy/paste from Excel

    In the past I've been able to drag or copy and paste an image from excel into Illustrator.  I've lost that ability (sometimes I'll get a shadow image copied in, but it is not in vectors and it is not editable).  If I save the figure as a PDF to copy it into Illustrator as a vector formatted object I cannot figure out how to change any formatting/colors.  I can select individual bars in a bar graph, I can add an outline to them, but the option for changing the color is completely absent.  I am fairly new to this, but would love help.  I've tried releasing the clipping masks, but that only fills in the entire body of the chart with color.  This literally all worked fine yesterday (and I can modify prior charts that I already imported with no problem).  I'd love some help and feedback as I am fairly new to this and could be missing something! Thanks.

    I can't get a PDF picture, ai picture, or EPS figure to post on here so I don't know how useful an image will be, but I added a jpeg that shows the shadowing I get when I copy in at times. . 

  • HP Prime: how would you approach this vector problem

    Given:   r1 = 2i-j+k 
                    r2 = i+3j-2k
                    r3 = -2i+j-3k
                    r4 = 3i+2j+5k
    if r4 = ar1+br2+cr3  find the values for a, b, c
    If I use the Solve App I have five equations with three unknowns and Solve App doesn't like that  "Must select as many variables as equations"   If I select five variables I get "no solution could be found"
    I tried using the 'solve'  function in the CAS mode, but it can only solve for ONE variable.   Seems like the only way I can solve this problem is by hand???   any suggestions???

    Thanks for the encouragement,  I wasn't so much stuck as I was trying to find out the power / limitations of the HP Prime.  
    I was disappointed to find out that the Prime doesn't seem to know the difference between the small letter i (alpha-Tan) and the complex i (shift-2)  so that took awhile to figure out if I was making a mistake (why have two difference key stokes if they are both the same) or this was a peculiarity of the program.  Equally frustrating was entering an equation using the small letter i,  I could not tell if I was entering a complex number or a variable or a vector as there are so many different forms the complex number takes or I just can't tell the difference.  Sometimes it is written  2+3*i;  sometimes as [2 3*i]; 
    i enter 2+3*(alpha TAN)  and i get 2+3*i     same results if i use (shift 2)
    i enter ( 2+3*(alpha TAN))  and i get 2+3*i   drops the parenthesis 
    i enter (2,3(alpha TAN)) and i get [2 3*i]     why the change from parenthesis to brankets when brankets are used for matrices???  why the dropping of the comma??? i gather the brankets without the comma is a vector - just confusing having to enter with a comma but it is displayed without the comma - not very good reenforcement.  
    I enter (2,3i)*(4,5i) displays as [2 3*i]*[4 5*i]  result is -120
    I enter [2 3i]*[4 5i] displays as [2 3*i]*[4 5*i]  result is -7,    both entries on the left side look the same but the right side is different????  I have no idea what is going on here???
    I enter(2+3i)*(4+5i) displays the same, result is -7+22*i
    I enter 2+3i*4+5i displays as 2+3*i*4+5*i, result is 2+17*i
    still confusing
    anyway  back to the problem - gave up on entering variables, just used the Linear Solver, columns x,y,z became a,b,c and rows 1,2,3  became i,j,k   the solution  (-2, 1, -3)  
    I tried your "Munk" , no function of that name in the catelog - didn't work....
    Used M1^-1 * M2 and got the same results as I got in Linear Solver... 
    can you enlight me on complex numbers versus vectors versus whatever else I was entering,   thanks

  • VEctor: Problem in arithmetical operation

    The problem with the following code is that when an element is accessed with v.elementAt() the compilation is OK. But if I try to do some arithmetic operation on the element, it won't compile, giving the message -
    VectorDemo.java:36: operator * cannot be applied to java.lang.Object, int
    System.out.println("Result: "+v.elementAt(3)*2);
    Is it because of <Object> type declaration of Vector? If so how to do arithmetic operation with an element of a vector which may have Double, Float or Integer type of elements in the same vector?
    import java.util.*;
    class VectorDemo
         public static void main(String args[])
              Vector<Object> v=new Vector<Object>(3,2);
              System.out.println("Initial size: "+v.size());
              System.out.println("Initial capacity: "+v.capacity());
              v.addElement(new Integer(1));
              v.addElement(new Integer(2));
              v.addElement(new Integer(3));
              v.addElement(new Integer(4));
              System.out.println("Capacity after four additions: "+v.capacity());
              v.addElement(new Double(5.45));
              System.out.println("Current capacity : "+v.capacity());
              v.addElement(new Double(6.08));
              v.addElement(new Integer(7));
              System.out.println("Current capacity : "+v.capacity());
              v.addElement(new Float(9.4));
              v.addElement(new Integer(10));
              System.out.println("Current capacity : "+v.capacity());
              v.addElement(new Integer(11));
              v.addElement(new Integer(12));
              System.out.println("First element : "+v.firstElement());
              System.out.println("Last element : "+v.lastElement());
              System.out.println("Find Result: "+v.elementAt(3));     //<------ if replaced with:
                                    //System.out.println("Find Result: "+v.elementAt(3)*2);
              if(v.contains(new Integer(3)))
                   System.out.println("Vector contains 3.");
              Enumeration vEnum=v.elements();
              System.out.println("\nElements in vector: ");
              while(vEnum.hasMoreElements())
                   System.out.println(vEnum.nextElement()+" ");
              System.out.println();
    }

    Here's the correct code.
    import java.util.*;
    import java.lang.Number;
    class VectorDemo
         public static void main(String args[])
              //initial size is 3, increment is 2
              String s;
              int i=0;
              Vector<Number> v=new Vector<Number>(3,2);
              System.out.println("Initial size: "+v.size());
              System.out.println("Initial capacity: "+v.capacity());
              v.addElement(new Integer(1));
              v.addElement(new Integer(2));
              v.addElement(new Integer(3));
              v.addElement(new Integer(4));
              System.out.println("Capacity after four additions: "+v.capacity());
              v.addElement(new Double(5.45));
              System.out.println("Current capacity : "+v.capacity());
              v.addElement(new Double(6.08));
              v.addElement(new Integer(7));
              System.out.println("Current capacity : "+v.capacity());
              v.addElement(new Float(9.4));
              v.addElement(new Integer(10));
              System.out.println("Current capacity : "+v.capacity());
              v.addElement(new Integer(11));
              v.addElement(new Integer(12));
              System.out.println("First element : "+v.firstElement());
              System.out.println("Last element : "+v.lastElement());
              System.out.println("Result: "+Integer.parseInt(v.elementAt(3).toString())*2);
              if(v.contains(new Integer(3)))
                   System.out.println("Vector contains 3.");
              //enumerate the elements in the vector.
              Enumeration vEnum=v.elements();
              System.out.println("\nElements in vector: ");
              while(vEnum.hasMoreElements())
                   System.out.println(vEnum.nextElement()+" ");
              System.out.println();
    }

  • Trigger, catproc.sql : ICD Vector problem, plz help

    oracle 817, win2000
    I accidently excuted this script
    HOME\rdbms\admin\catproc.sql
    while connected as system, not as sys.
    Afterwards i executed it on sys (still not without errors, but alot less)
    Now, the manager account is behaving rather weird. im getting alot of errors like this one trying to load some java stored procedures to the DB:
    initialization complete
    loading : MyRep
    Error while loading MyRep
    ORA-06509: PL/SQL: ICD-vector is missing for this package
    ORA-06512: at "SYSTEM.DBMS_LOB", line 492
    ORA-06512: at line 1
    Obviously i've messed with something i shouldnt mess with.. how can i resolve it short of a reinst of 817 ?
    Thx in advance.
    null

    Bruce,
    I think what happened is that you should have logged in as
    sys instead of system when you run the catproc.sql. So, now you
    have a package created for sys and system. What I suggest to you
    is that you go into DBA Studio and remove the package(s)
    (duplicate ones) and then you should be alright. I hope this
    will solve your problem.
    Steve Siew

  • Nested vectors problem

    Hi,
    I'm having a bit of a problem trying to create a vector within a vector. I am parsing a string and adding the elements to a vector. Then after I've done this I want to add the newly populated vector to another vector, then clear the original vector and start again. Thus adding "rows" and "columns" to create a 2D array as a vector.
    However, my problem comes when I try to clear the first vector after I've added it's contents to the containing vector. When I call the clear(); function it does clear the vector, but it also clears it from containing vector I've just added it to! Surely this can't be right? What's the way around this?
    String rows = "";
    Vector vCols = new Vector();
    Vector vRows = new Vector(vCols);
    // Split on rows
    StringTokenizer stRows = new StringTokenizer(rows, "][");
    //while rows remaining, put contents in vector
    while (stRows.hasMoreTokens()) {
    //split on ']['
    //clearing this also remove the contents already put into vRows !!
    vCols.clear();
    rows = stRows.nextToken(); // contains A row!
    StringTokenizer stCols = new StringTokenizer(rows, ",");
              //now parse the columns
    while (stCols.hasMoreTokens()) {
    String d = stCols.nextToken();
    vCols.addElement(d);
    vRows.addElement(vCols);
    TIA
    ~PAul Phillips

    Use [code ] tags when pasting code to make the code readable. Click on the "Formatting Help" link before you post your next thread for more information.
    You can't just 'clear' a Vector and and more data to it you need to create a new Vector for every row. This thread shows a similiar example on creating a Vector of Vectors from a ResultSet from an SQL query:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=497641

  • Vectors Problem.

    Hi,
    I was wondering if anyone could shed some light on this problem, I've been tearing my hair out all day.
    I have a mouselistener capturing points, and the listener should add the points to a vector. The command line output is adding the 1st element once, the second element twice and so on. So the index is increasing, but the point is added a multiple of the index.
    This sets up the vector and index in the method that sets up the JFrame:
              nodes = new Vector();
              index = 0;This is my problem method:
       public void mouseClicked(MouseEvent e){
             int x = e.getX();          //captures the point
            int y = e.getY();
                if (point == null) {
                    point = new Point(x, y);
                } else {
                    point.x = x;
                    point.y = y;
           repaint();
           nodes.add(index,point);            // adds the point to the vector
           index++;               //vector index
           System.out.println(nodes);          //prints the contents
           System.out.println(nodes.size());     //prints length of vector
         } Example output:
    [Java.awt.Point[x=10,y=10]],
    1
    [Java.awt.Point[x=20,y=20],[Java.awt.Point[x=20,y=20]]
    2
    [Java.awt.Point[x=30,y=30],[Java.awt.Point[x=30,y=30],[Java.awt.Point[x=30,y=30]]
    3

    The command line output is adding the 1st element once, the second element twice and so on.I really don't know waht you mean by that. It would have been great to see some output that you wish would be.
    I'll give it a shot though. And please correct me on my assumptions.
    First, Vector.add(int index, Object obj) method inserts objects at specified index, nothing more.
    On the other hand, Vector.add(Object obj) method appends objects at the end of Vector.
    Second, you are creating one and only one Point object in the entire execution.
    When you reset the x y attributes of your object, this does not create another one.
    So if you want different objects in the Vector, you must create one at each mouseClicked() call.
    My assumption is that you are trying to achieve this, for instance at index 3:
    [Java.awt.Point[x=10,y=10],[Java.awt.Point[x=20,y=20],[Java.awt.Point[x=20,y=20],[Java.awt.Point[x=30,y=30],[Java.awt.Point[x=30,y=30],[Java.awt.Point[x=30,y=30]]
    3
    If so, then you should do:
        public void mouseClicked(MouseEvent e) {
            int x = e.getX();       //captures the point
            int y = e.getY();
            Point point = new Point(x, y);
            repaint();
            for (int i = 0; i <= index; i++)
                nodes.add(point);          // adds the point to the vector
            index++;         //vector index
            System.out.println(nodes);       //prints the contents
            System.out.println(nodes.size());    //prints length of vector   
        }I may be flat wrong with that assumtion. If this is the case please repost clearer specs of what the output should look like.

  • Need help with Vector problem

    I'm creating a vector from a recordset, which i will use for paging purposes. I searched the posts for this but didn't find any good answers. Anyway, here's what I have. It's all in the JSP page (at least for now):
         Vector dataVector = new Vector();
         Vector rowVector;
         ResultSetMetaData rsmd = rset.getMetaData();
              int count = rsmd.getColumnCount();
                   while (rset.next() ) {
                        rowVector = new Vector();
                        for (int i = 1; i <= count ; i++) {
                             rowVector.addElement(rset.getObject(i));
                   dataVector.addElement(rowVector);
    %>
    // HTML STUFF
    <%
    for(int a = 0; a <= dataVector.size(); a++) { %>
    <p> <%= dataVector.elementAt(a) %> </p>
    <% } %>
    And I get the following error:
    java.lang.ArrayIndexOutOfBoundsException: 2 >= 2
         at java.util.Vector.elementAt(Vector.java:417)
         at org.apache.jsp.untitled$jsp._jspService(untitled$jsp.java:116)
         at
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107........
    I'm selecing 3 columns from the DB table, for a total of 2 records pulled (It's a test platform). So, any ideas?
    Thanks
    Mike Gernhardt

    size will return the total number of objects within the vector and not the max index of the vector.
    a <= dataVector.size(); a++) { %>
    will obviously throw a runtime exception(
    java.lang.ArrayIndexOutOfBoundsException)
    making it a<dataVector.size(); a++) { %> will take care of the problem.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                

  • A vector problem

    I am trying to write a source in witch i save data of my vector in a file. It worked a while ago, but it seems i�ve changed something without me knowing it. This is a part of my source code can anyone find my problem and solve it?
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;                         
    import java.io.*;
    public class hello extends JFrame {
    private JButton addBtn;          
    public hello() {
    super("Vector voorbeeld");
    final JLabel status = new JLabel();
    Container c = getContentPane();
    c.setBackground(Color.white);
    c.setLayout(null);     
         c.setBackground(Color.white);
    final Vector v = new Vector(1);
    c.add(new JLabel("String"));
    final JComboBox input = new JComboBox(v);
    input.setBounds(40, 30, 130, 25);
    input.setBackground(Color.white);
    input.setEditable(true);
    c.add(input);
    addBtn = new JButton("Toevoegen");
    addBtn.setBounds(40, 90, 130, 25);
    c.add(addBtn);
    addBtn.addActionListener(
    new ActionListener() {
    public void actionPerformed( ActionEvent e)
    v.addElement(input.getSelectedItem());
    status.setText("added add the end: " +
    input.getSelectedItem());
    input.setSelectedItem("");
    JButton removeBtn = new JButton("Delete");
    removeBtn.setBounds(40, 120, 130, 25);
    removeBtn.addActionListener(
    new ActionListener() {
    public void actionPerformed(ActionEvent e)
    if (v.removeElement(input.getSelectedItem()))
    status.setText("Verwijderd: " +
    input.getSelectedItem());
    else
    status.setText(input.getSelectedItem() +
    " niet in vector");
    input.setSelectedItem("");
    c.add(removeBtn);
    JButton firstBtn = new JButton("first");
    firstBtn.setBounds(40, 150, 130, 25);
    firstBtn.addActionListener(
    new ActionListener() {
    public void actionPerformed(ActionEvent e)
    try {
    status.setText("First element: " +
    v.firstElement());
    catch (NoSuchElementException exception) {
    status.setText(exception.toString());
    c.add(firstBtn);
    JButton lastBtn = new JButton("Last");
    lastBtn.setBounds(40, 180, 130, 25);
    lastBtn.addActionListener(
    new ActionListener() {
    public void actionPerformed(ActionEvent e)
    try {
    status.setText("Last element: " +
    v.lastElement());
    catch (NoSuchElementException exception) {
    status.setText( exception.toString() );
    c.add(lastBtn);
    JButton emptyBtn = new JButton("Is Leeg?");
    emptyBtn.setBounds(40, 260, 130, 25);
    emptyBtn.addActionListener(
    new ActionListener() {
    public void actionPerformed(ActionEvent e)
    status.setText(v.isEmpty() ?
    "Vector is empty" : "Vector is not empty");
    c.add(emptyBtn);
    JButton locationBtn = new JButton("Locatie");
    locationBtn.setBounds(40, 290, 130, 25);
    locationBtn.addActionListener(
    new ActionListener() {
    public void actionPerformed(ActionEvent e)
    status.setText("Element is on location " +
    v.indexOf(input.getSelectedItem()));
    c.add(locationBtn);
    JButton trimBtn = new JButton("Trim");
    trimBtn.setBounds(40, 320, 130, 25);
    trimBtn.addActionListener(
    new ActionListener() {
    public void actionPerformed(ActionEvent e)
    v.trimToSize();
    status.setText("Vector trimmed");
    c.add(trimBtn);
    JButton statsBtn = new JButton("Statistics");
    statsBtn.setBounds(40, 350, 130, 25);
    statsBtn.addActionListener(
    new ActionListener() {
    public void actionPerformed(ActionEvent e)
    status.setText("Groote = " + v.size() +
    "; capaciteid = " + v.capacity());
    c.add(statsBtn);
    JButton displayBtn = new JButton("Toon");
    displayBtn.setBounds(40, 380, 130, 25);
    displayBtn.addActionListener(
    new ActionListener() {
    public void actionPerformed(ActionEvent e)
    Enumeration enum = v.elements();
    StringBuffer buf = new StringBuffer();
    while (enum.hasMoreElements())
    buf.append(
    enum.nextElement()).append(" ");
    JOptionPane.showMessageDialog(null,
    buf.toString(), "Toon",
    JOptionPane.PLAIN_MESSAGE );
    c.add(displayBtn);
    JButton save = new JButton("Save");
    save.setBounds(40, 410, 130, 25);
    save.addActionListener(
    new ActionListener() {
    public void actionPerformed(ActionEvent e)
    String readLine= "";
    try {
    RandomAccessFile hello = new RandomAccessFile("gegevens.cfg", "r");
    for (int i=0; i < 1 && (readLine = hello.readLine()) != null; i++);
    catch (IOException f3) {}
    try {
    readLine=(v);
    FileOutputStream gegevens = new FileOutputStream("gegevens.cfg ");
    PrintStream myOutput = new PrintStream(gegevens);
    myOutput.println(readLine);
    catch (IOException j) {}
    System.out.println("the following is saved:"+ readLine);
         setVisible (false);
    c.add(save);
    c.add(status);
    setSize(200, 500);
    show();
    public static void main(String args[])
    hello app = new hello();
    app.addWindowListener(
    new WindowAdapter() {
    public void windowClosing(WindowEvent e)
    System.exit( 0 );
    }

    Hi,
    As suggestion, try to use the serialization features of Objects, instead
    writing and reading these elements. If you have a Vector and at each element you have a String you can serialize the object via ObjectInputStream and ObjectOutputStream :
    to write
         FileOutputStream ostream = new FileOutputStream("t.tmp");
         ObjectOutputStream p = new ObjectOutputStream(ostream);
         p.writeObject(your_Vector_instance);
         p.flush();
         ostream.close();
    and to read
         FileInputStream istream = new FileInputStream("t.tmp");
         ObjectInputStream p = new ObjectInputStream(istream);
         int i = p.readInt();
         Vector your_vector_instance = (Vector)p.readObject();
         istream.close();
    P.D. do these op. is possible because Vector implements Serializable and
    String also. If you put into some Vector element an Object be sure implements Serializable
    Hope this help

  • Vector Problems...

    Hi,
    i am having a problem adding to a vector at a specific index. in the code below when run it gives an array index out of bounds at:      notesRange.add(ii, noteVector); can anyone offer any ideas to why it wont let me add into that index of the vector?
    thanks
    Cav.
    code:
         public static void noteRange()
              noteNameArray();
              getAllNoteEvents(0);
              System.out.println("notes Array: " +notesArray.length);
              Vector notesRange = new Vector(127);
              for(int i=0;i<allNotesVector.size(); i++)
                   System.out.println("i: " +i);
                   Vector noteVector = (Vector)allNotesVector.get(i);
                   String noteName = (String)noteVector.get(1);
                   for(int ii=0; ii<notesArray.length; ii++)
                        System.out.println("ii: " +ii);
                        if(noteName == notesArray[ii])
                             System.out.println("IN");
                             System.out.println("NotesRangeSize: " +notesRange.size());
                             notesRange.add(ii, noteVector);
              System.out.println(notesRange);
         }

    so is there no way i can create my vector with 127 spaces and then put my first element into it in any space other then '0'?
    heres the code looking a bit better:
         public static void noteRange()
              noteNameArray();
              getAllNoteEvents(0);
              System.out.println("notes Array: " +notesArray.length);
              Vector notesRange = new Vector(127);
              for(int i = 0;i < allNotesVector.size(); i++)
                   System.out.println("i: " +i);
                   Vector noteVector = (Vector)allNotesVector.get(i);
                   String noteName = (String)noteVector.get(1);
                   for(int ii = 0; ii < notesArray.length; ii++)
                        System.out.println("ii: " +ii);
                        if(noteName = = notesArray[ii])
                             System.out.println("IN");
                             System.out.println("NotesRangeSize: " +notesRange.size());
                             notesRange.add(ii, noteVector);
              System.out.println(notesRange);
         }

  • PDF vector problem - ASAP please

    Hi, I have created design document in InDEsign with links to Photoishop files and AI ( vector files )
    After exporting this document into PDF Press Quality file for sending it to print - all Logos ( vector AI files ) looks so awful !
    Why PDF is flatten them to so low quality ?
    The reason to keep them ( logos ) in vector format is to get fine quality print !
    What do I have to do with them ?
    Please help. Thanks.

    Well, could be Acrobat... Try the smoothing preferences.

  • Storing into vector problem

    I am storing my documentID etc into setter methods and vector in my database class. DocumentID field is an auto number field in access database. e.g there are 7 records in the database and by right the documentID should be from 1 to 7. When i retrieve the contents from vector in my servlet class, all 7 records' documentID are 7 but not from 1 to 7. And this occurs when i add the yb instance into a vector. it works alright when i do a System.out.println() within the while loop(before adding into a vector). My qns is why is it that the last record number is being displayed instead of 1 to 7? if my codes were to be the one displayed below, it works:
    while(rs.next())
    v.add(rs.getString("DocumentID"));
    // inside Database class
    // e.g all 7 records' DocumentID would display 7 instead of 1 to 7.
    while(rs.next()){
    YourBean yb = new YourBean();
    yb.setDocument(rs.getString("DocumentID"));
    yb.setDocName(rs.getString("DocName"));
    yb.setStateCode(rs.getString("State_Code"));
    yb.setOriginator(rs.getString("Originator"));
    v.addElement(yb);
    stmt.close();
    con.close();
    catch(SQLException e){
    System.out.println(e);
    e.printStackTrace();
    return v;

    A static field is one that is declared as "static". Like this:private static String document;If you did that then there's only one instance of the variable for the class.

  • Simple vector problem

    I need to add a double and a string as one element in a vector.
    I can add doubles by themselves, however adding a string with it, doesnt seem to work.
    test.addElement((new Double( 20)),(new String (star))));
    Cheers for any help

    basically you will need to add them separately or create your own class with a double and string in it and add this class to the vector
    class twoVals {
        double dbl;
        String str;
        twoVals(double dbl, String str) {
            this.dbl = dbl;
            this.str = str;
    twoVals addingElement = new twoVals(20.0, "star");
    test.addElement(addingElement);to get it back
    twoVals retVal = (twoVals)test.elementAt(0);

  • Strange vector problem

    Hi all. I get the following error while compiling some code with CC 5.3. After much effort I haven't been able to figure it out and it's driving me nuts. Hope someone can provide some insight.
    I have a class that has two member variables that are
    vector<RWCString> and a member function that takes 'const vector<RWCString>' as one of its arguments. When compiling this code I see the following errors:
    "/opt/SUNWspro6/WS6U2/include/CC/Cstd/./vector.cc", line 52: Error: "," expected instead of "6".
    "/opt/SUNWspro6/WS6U2/include/CC/Cstd/./vector.cc", line 52: Error:  Expected "class" or "typename" before "6" .
    "/opt/SUNWspro6/WS6U2/include/CC/Cstd/./vector.cc", line 53: Error: Template parameter std::T requires a type argument.
    "/opt/SUNWspro6/WS6U2/include/CC/Cstd/./vector.cc", line 54: Error: Could not find partial specialization matching std::vector<6, std::Allocator>.
    "/opt/SUNWspro6/WS6U2/include/CC/Cstd/./vector.cc", line 54: Error: Arguments out of order for std::vector<6, std::Allocator>.
    etc. (there are several more lines of such errors)----------------------------------------
    I have NO idea where the "6" is coming from.
    Has anyone seen anything like this before? Any help would be appreciated. Thanks a lot in advance.
    spchan

    You probably have a macro in your code that is conflicting with the headers. Look for #define T ...
    #define Allocator ...
    Also, since you are using the C++ standard library with RWTools.h++, be sure you use the option
    -library=rwtools7_std on each CC command line, not just rwtools7.

Maybe you are looking for

  • [Solved] Emoji fonts in URxvt

    I'm attempting to get emoji (and ideally the entire utf8 set) working in my terminal and other programs. In my .Xresources I previously had just Terminus, I've found that Symbola is the font that you want to display emoji? So I figured that the follo

  • Business Partner not created via MDS_LOAD_COCKPIT

    Hi, I have a question. It seems to our customer are not being replicated when I run the Sync Cockpit. I have checked all config: Config for BP<-> Cust Number ranges, groupings, roles, PPO active, Cust integration etc. It all seems the same in the con

  • No stars in Top Sites

    I no longer have stars indicating new content in top sites.  I have reset Safari Top Sites, and deleted the Safari cache as recommended elsewhere in these forums to no avail.  I moved the Safari plist to the desktop, as also recommended in these foru

  • Adding JButton in BorderLayout

    Hi everyone, I have a question about Panel. I want to know how can we add 2 button at the bottom of panel2 and then add panel2 into panel1. here is what I did.      // 2 buttons for panel2      JButton b1 = new JButton ("Start");      b1.addActionLis

  • U44M1P34 error

    I got the above errormsg when updating Indesign CC 9.2.1. Followed the the error recovery instructions (uninstall, remove folders ...). Reinstalled the app, but now the patch failed and Indesign won't start anymore. Suggestions? Gert