Write to a vector

Hi all, appreciate if you could help me. I have a program used to query from database(oracle) and then dump it to vector and later on write to local drive. this vector contains few columns. my problem is, i would like to replace column b with a new Value. how ca i do that? Please advise.
below are my code.
thanks.
SQLStore storeTB = new SQLStore("GENERAL_S010");
storeTB.setArg("001", currInfos);
list3 = dbwrap.selectList(storeTB);
String sTitleLine = "";
String sLine = "";
if(list3 !=null && list3.size() >0 ){
                                   GENERAL_ENT gent2 = (GENERAL_ENT)list3.get(0);
                                   for (int j=0; j<gent2.getColCnt();j++ ){
sTitleLine += (sTitleLine.length()>0?"\"\t\"":"\"");
sTitleLine += gent2.getCol(j);
sLine +=(sLine.length()>0?"\"\t\"":"\"");
sLine += gent2.getVal(j);
                                   String dt="";
     dt = gent2.getVal(19);
     System.out.println (">>>>col:" +dt);
     if (dt == null) return "";
     if (dt.indexOf("L") > -1){
     dt = "LAYOUT";
     }else if (dt.indexOf("A") > -1){
     dt = "ASSEMBLY";
     }else                               dt = "PACKAGE";
     list3=gent2.setVal("I", "INT");
     sTitleLine = "%" + sTitleLine + "\"\n";
fw.write (sTitleLine); //write Titleline onto the physical file
sLine = "" + sLine + "\"\n"; //write attributes
fw.write(sLine);
fw.flush (); //Flushes all resources being used by this Image object
fw.close ();

http://forum.java.sun.com/help.jspa?sec=formatting Still hard to read, though, and highly procedural.
I don't understand how a Vector contains a column and where you want to replace what.

Similar Messages

  • List v = new Vector() how can i write this ?

    List v = new Vector() how can i write this ?
    vector does not 'extends' List rather it 'implements' only ......so how can write this way ? ( polymorphism applies only for 'extends' ).

    my question in a simple way is :
    List some_list extends Vector
    No, List is an interface; Vector is a concrete class. Read the javadocs.
    Vector implements List
    >
    AND
    List some_list implements Vector
    are these two same in behaviour
    our  apart from theoretical differences ?thanks
    Interfaces don't have any implementation; they're pure method signatures. When a concrete class implements an interface, it makes a promise that says "I will provide implementations for exactly these methods. Any client can call a method from the interface and I will do something 'sensible' if I'm written correctly."
    From the point of view of static and dynamic types, there's no difference between interfaces and classes.
    C++ has interfaces, too - they're classes with all pure virtual methods. If you understand how C++ works, the concept shouldn't be hard.
    ArrayList is preferred precisely because it isn't synchronized by default. (You can always make it so using java.util.Collections if you wish later on.) If you don't need synchronization, why pay the performance penalty?

  • Writing a Vector to a Output File Line by Line.

    Can anyone tell me how to write each element of the Vector on a New Line to the Output file? Right now the Output is in a String across 1 line.
    Now - � t Bowser 5 years 105 lbs.t Bowser 5 years 106 lbs.t Daisy 1 year 30 lbs.t Dog 1 yr 66 lbs.t King 6 years 77 lbs.t Nikki 5 years 68 lbs.
    Here is what I need -
    Bowser 5 years 106 lbs.
    Bowser 5 years 105 lbs.
    Rover 7 years 88 lbs.
    Dog 1 yr 66 lbs.
    King 6 years 77 lbs.
    Nikki 5 years 68 lbs.
    Daisy 1 year 30 lbs.
    Do a find on // Writes Vector Object to a file
    Thank You in advance.
    import java.io.*;
    import java.awt.*;
    import java.util.*;
    public class VectorSort
    Vector v;
    private DataInputStream inputStream = null;
    private ObjectOutputStream outputStream = null; // <== this is for a Vector
    // private DataOutputStream outputStream = null; // <== This is for a Textfile
    (1) Read in Pet Records put them in a Vector, Sort them Print them.
    public static void main(String[] args) throws java.io.IOException
    VectorSort newVector = new VectorSort();
    newVector.connectToInputFile();
    newVector.connectToOutputFile();
    newVector.readInput();
    newVector.sortPrint();
    newVector.closeFiles();
    System.out.println(" ");
    System.out.println("Check A:/DataOut.txt Now");
    public void connectToInputFile()
    String inputFileName = getFileName("Enter input file name: A://DataIn.txt");
    try
    inputStream = new DataInputStream(new FileInputStream(inputFileName));
    catch(FileNotFoundException e)
    System.out.println("File " + inputFileName + " not found.");
    System.exit(0);
    public void connectToOutputFile()
    String outputFileName = getFileName("Enter output file name: A://DataOut.txt");
    try
    outputStream = new ObjectOutputStream( // <== this is for a Vector
    // outputStream = new DataOutputStream( // <== this is for a Textfile
    new FileOutputStream(outputFileName));
    catch(IOException e)
    System.out.println("Error opening output file "
    + outputFileName);
    System.out.println(e.getMessage());
    System.exit(0);
    private String getFileName(String prompt)
    String fileName = null;
    System.out.println(prompt);
    fileName = SavitchIn.readLineWord();
    return fileName;
    //===========================================================================
    public void readInput()
    v = new Vector ();
    try
    String result = "";
    boolean done = false;
    int ctr = 0;
    String next;
    next = inputStream.readLine();
    while ( next != null)
    v.addElement( next.trim() );
    next = inputStream.readLine();
    catch(EOFException e)
    //Do nothing. This just ends the loop.
    System.out.println("Do Nothing Here");
    catch(IOException e)
    System.out.println(
    "Error: reading or writing files.");
    System.out.println(e.getMessage());
    System.exit(0);
    public void sortPrint()
    Collections.sort(v);
    int vsize = v.size();
    for (int j = 0; j < vsize - 1 ; j++)
    try
    outputStream.writeObject(v.elementAt(j)); // Writes Vector Object to a file
    System.out.println(v.elementAt(j));
    catch(IOException e)
    System.out.println("Error Writing Output "
    + e.getMessage());
    System.exit(0);
    public void closeFiles()
    try
    outputStream.flush(); // <== force the buffer to write
    inputStream.close();
    outputStream.close();
    catch(IOException e)
    System.out.println("Error closing files "
    + e.getMessage());
    System.exit(0);

    // did you try with java.io.PrintWriter
    // here is simple method to write file from vector.
    // you need to change obtaining your string value at the vector loop
    private void writeDataLog(Vector vector, String filename)
    try
    PrintWriter pw = new PrintWriter(new FileWriter(filename, true));     
    if (vector.size()>0)
    for (int i=0; i<vector.size(); i++)
    { String str = ((your object)vector.get(i)).getYourString();
    pw.println( str );
    pw.close();
    catch(Exception e)
    { System.out.print(e.toString()); }
    }

  • Problem With Quicksorting a Vector

    Hi there!
    I tried to write an extended Vector which can perform a quicksort of itself.
    Unfortunately, after the quicksort, everything int his Vector seems "damaged" - although I get the right Strings out of it, the don't seem to be internally right. ANyway, I'll post my code here and hope anyone can tell me what is wrong with it ;-)
    public class SortingVector extends java.util.Vector {
         public SortingVector() {
              super();
         public SortingVector(int i, int j) {
              super(i, j);
         public void sortStrings() {
              quickSortStrings(0, this.size() - 1);
         private void quickSortStrings(int l, int r) {
              if (l < r) {
                   int r2 = partitionStrings(l, r);
                   quickSortStrings(l, r2);
                   quickSortStrings(r2 + 1, r);
         private void exchange(int m, int n) {
              Object o1 = this.elementAt(m);
              this.set(m, this.elementAt(n));
              this.set(n, o1);
         private int partitionStrings(int m, int n) {
              String x = ((String) this.elementAt(m)).toLowerCase(); // Pivot-Element
              int j = n + 1;
              int i = m - 1;
              while (true) {
                   j--;
                   while (checklarger(j, x)) {
                        j--;
                   i++;
                   while (checksmaller(i, x)) {
                        i++;
                   if (i < j)
                        exchange(i, j);
                   else
                        return j;
         private boolean checklarger(int j, String x) {
              int count = 0;
              String element = ((String) this.elementAt(j)).toLowerCase();
              while ((element.charAt(count) == x.charAt(count))
                   && (count < element.length() - 1)
                   && (count < x.length() - 1)) {
                   count++;
              if (element.charAt(count) > x.charAt(count)) {
                   return true;
              return false;
         private boolean checksmaller(int j, String x) {
              int count = 0;
              String element = ((String) this.elementAt(j)).toLowerCase();
              while ((element.charAt(count) == x.charAt(count))
                   && (count < element.length() - 1)
                   && (count < x.length() - 1)) {
                   count++;
              if (element.charAt(count) < x.charAt(count)) {
                   return true;
              return false;

    Unfortunately, after the quicksort, everything int his
    Vector seems "damaged" - although I get the right
    Strings out of it, the don't seem to be internally
    right.I also think you should use the built-in sort but what do you mean by "damaged"?

  • Monitoring a vector

    Hi all
    Been too busy to post recently, but have a problem that I want to debug and need some help on how to do it.
    I am reading an xml file and creating some objects based on it's contents, and then storing these objects in a vector. I am then writing out all of the contents of the Vector (again in XML). What I have found in debugging is that I am reading 3 objects, and they are quite happily added to the vector. However, when I come to write out said vector some other piece of code has modified it and it seems there is only 1 element left ( the first).
    What I would like to do is add some sort of monitor to the vector so that I get a notifocation of when it's size changes ( or when something is added/removed ), and then try to work out what caused it to resize. Can I do this without creating a MyVector class that overrides some of the methods of Vector?

    So you want to change the behavior of Vector without creating a subclass? I suppose you could change the source to Vector and recompile it, but yuck.
    Do you have access to a debugger? You could throw the whole thing on a debugger and put a breakpoint at Vector.remove, etc.

  • How to Store Vector in Oracle8i Database

    Hi Friends,
    I am using Oracle8i database and jdbc2.0. How can I store a vector java object in Oracle8i ....
    Finally I want to store a java vector in a column of a table and while retrieving from the resultset I can typecast it directly to a java Vector type and use... ????
    Any code examples, urls, links will be appreciated.
    Thanks in advance....

    The code below should allow you to write any object you want to a Blob. I am using it to write out the Vector xData and read it back in. Please note, I am using the ByteArrayInputStream and ByteArrayOutputStream classes. Also, the InputStream.available() method returns a null if you try to use it for size. Good Luck
    // create section to test out graphing capability. will generate a vector to plot, generate the plot, try to write it out to
    // a file. Just check that we can perform these actions.
    // Create an option dialog box for user input on what assembly to test
    Vector xData = new Vector();
    Vector recoveredYData;
    JFreeChart chart;
    for(int nCount = 0; nCount < 250; nCount++)
    xData.addElement(new Double(Math.cos(nCount/10.0)));
    try{
    ByteArrayOutputStream baOS = new ByteArrayOutputStream();
    ObjectOutputStream tempObjOS = new ObjectOutputStream(baOS);
    tempObjOS.writeObject(xData);
    tempObjOS.close();
    ByteArrayInputStream baIS = new ByteArrayInputStream(baOS.toByteArray(), 0, baOS.size());
    tempObjOS.close();
    baOS.close();
    int inBytes = baIS.available();
    String holdString = "Insert Into StepResults (SerialNumber, STEPS_ID, OperatorID, Result, RunNumber, TestsID, AssyID) "+
    "VALUES ('0', 0, 0, 'PASS', 0, 0, 0)";
    this.DBConnect.statement.executeUpdate(holdString);
    System.out.println("Execute Query for Update");
    PreparedStatement pstmt = DBConnect.connection.prepareStatement("Update StepResults Set PlotData = ? where AssyID = 0 and TestsID = 0 and RunNumber = 0 and SerialNumber = '0'");
    pstmt.setBinaryStream(1, baIS, baIS.available());
    pstmt.executeUpdate();
    ResultSet rs = this.DBConnect.statement.executeQuery("Select * from StepResults Where AssyID = 0 and TestsID = 0 and RunNumber = 0 and SerialNumber = '0'");
    System.out.println("Try to get data back from database");
    holdString = "Select * from StepResults Where AssyID = 0 and TestsID = 0 and RunNumber = 0 and SerialNumber = '0'";
    rs = this.DBConnect.statement.executeQuery(holdString);
    if(rs != null)
    if(rs.next())
    System.out.println("Check for PlotData in resultSet");
    InputStream is = rs.getBinaryStream("PlotData");
    System.out.println("Bytes available from InputStream: " +inBytes);
    byte newByte[] = new byte[inBytes];
    if(is == null)
    System.out.println("Null Pointer Returned from BinaryStream");
    is.read(newByte, 0, inBytes);
    ByteArrayInputStream baISb = new ByteArrayInputStream(newByte);
    System.out.println("InputStream class: " +is.getClass().toString());
    ObjectInputStream ois2 = new ObjectInputStream(baISb);
    recoveredYData = (Vector) ois2.readObject();
    ois2.close();
    baISb.close();

  • Y in java objects are created on heap only and not on stack ??

    Hi ,
    I need a answer to the question " why all the objects are created on heap only in java and not on stack " ?
    In java a object is created when we specify new i.e. for example,
    consider the following cases.
    1.
    Vector v = new Vector();
    here object is created and the reference to this object is assigned to variable v. okie.
    2.
    when i write something like
    Vector vec ;
    Here i am creating reference variable for Vector. No object is created and no seperate memory is allocated for it. Reference variablesa are stored along with other primitive variables on the java stack.
    My question is, in C++ by writing case 2 i can create an object and it is creating this object on stack. So why in java object is not created on stack while i do like this ? Why in java objects are created on heap only ?
    If my question is out of interest of this forum i apologize for it. But if somebody can throw some light on it, it would be of great help.
    Cheers !!
    Dipesh

    Hi
    I asked this question just to understand how compiler and jvm cud have been designed......i.e. to know the philosophy behind designing language.......
    now what i cud surmise is that if objects were to be stored in stack then on calling garbage colllector , it may delete some unused obj and unreferenced object(unreachable object) and this in turn may give rise to non-contagious areas in stack, thus nullifying the garbage collector's objective of freeing the the memory. Again deallocating that intersperse spaces into one free block of space will be bit troublesome task.....
    So considering above factor the designer of jvm and java compiler have opted for storing objects on heap rather than stack.....
    If u have something to say bout this.......pls go ahead.......
    Cheers !!
    Dipesh

  • Y in java objects are created on heap only n not on stack ?

    Hi ,
    I need a answer to the question " why all the objects are created on heap only in java and not on stack " ?
    In java a object is created when we specify new i.e. for example,
    consider the following cases.
    1.
    Vector v = new Vector();
    here object is created and the reference to this object is assigned to variable v. okie.
    2.
    when i write something like
    Vector vec ;
    Here i am creating reference variable for Vector. No object is created and no seperate memory is allocated for it. Here this reference is placed on the java stack along with other primitive data types.
    My question is, in C++ by writing case 2 i can create an object and it is creating this object on stack. So why in java object is not created on stack while i do like this ? Why in java objects are created on heap only ?
    If my question is out of interest of this forum i apologize for it. But if somebody can throw some light on it, it would be of great help.
    Cheers !!
    Dipesh

    Cross post!
    http://forum.java.sun.com/thread.jsp?forum=32&thread=260589

  • JFileChooser - setSelectedFile doesn't work

    Hi,
    I'm using J2SE 1.4.1_01
    I want a suggested name to appear in the "File name" box when I use JFileChooser to save a file. I seem to remember this working fine with Java 1.3. I've seen it mentioned that I can use setText() on this, but don't understand how this can work. I've also tried explicitly setting the file as commented in my code
    This is my code....
    final JFileChooser fc = new JFileChooser();
    File outFile = new File("D:/EVA/Recombination/RATData/" + testSequence + ".csv");
    File dir = new File ("D:/EVA/Recombination/RATData");
    fc.setCurrentDirectory(dir);
    int returnVal = fc.showSaveDialog(null);
    if (returnVal == JFileChooser.APPROVE_OPTION)
    fc.setSelectedFile(outFile);
    /*also tried...
    fc.setSelectedFile(new File "D:/EVA/Recombination/RATData"+testSequence + ".csv"))*/
    try
    PrintWriter writ = new PrintWriter(new FileWriter(outFile));
    etc, etc.......
    Any suggestions?
    Cheers

    Thanks. It now works I had to change the PrintWriter to a BufferedWriter for it to work. I've posted working code below
    final JFileChooser fc = new JFileChooser();
    fc.addChoosableFileFilter(new FileFilterExt("Excel", new String[]{".csv"}));
    File outFile = new File(testSequence + ".csv");
    File dir = new File("D:/EVA/Recombination/RATData");
    fc.setCurrentDirectory(dir);
    fc.setSelectedFile(outFile);
    int returnVal = fc.showSaveDialog(null);
    if (returnVal == JFileChooser.APPROVE_OPTION)
    try
    String filename = fc.getSelectedFile().getAbsolutePath();
    BufferedWriter bw = new BufferedWriter(new FileWriter(filename));
    bw.write("whatever you want to write");// I'm writting from a Vector here, so this line is in a for loop.
    bw.flush();
    bw.close();
    catch (IOException e)
    System.out.print(e);
    Thanks for your help. My award will be made forwith.
    Cheers!

  • Will MV cause locking for FAST REFRESH

    Hi ,
    I want to create an MV on a table on a FAST REFRESH basis but this table is being constantly being updated/inserted and i am unsure of exactly the no of transactions but possibly in hundreds.
    1)
    with that in mind , would a FAST REFRESH on a schedule of every 10th mins be a good option and during the FAST REFRESH will it actually cause the master table to be locked and prevent updates/inserts from being done ?
    2)
    and during the time where my source database is down from re-org , there could be possibly changes in thousands e.g from 5000 - 10,000 , will a FAST REFRESH in this case bog down the source database then ?
    pls advise
    , in this case

    A fast refresh won't prevent you from doing DML on the source table. A fast refresh will generate additional load on the primary server, though, and there will also be additional load for every transaction on the source system that has to write a change vector into the materialized view log.
    If you're really concerned about the load on the source system, using Streams for your replication is designed to put much less load on the primary system.
    Justin

  • REDO LOG BUFFER

    Whenever a DML like Insert statement is issued it gets written to the Database buffer cache first by the server process(dedicated server).
    Which process writes this DML activity to the redo log buffer ?
    I guess DML is first written to the redolog files and only after that the same DML is committed to the data files.Is this correct ?
    Can get any references to read on how any activity/DML is processed with a Oracle architecture perspective.
    Thanks

    Yes.  Only the server process for that session knows what changes were made to the buffer cache.  So it is the only one that can write the change vectors to the redo log buffer.
    Hemant K Chitale

  • Oracle Hot Backup Confusion

    Hi everybody,
    This is regarding a confusions on Oracle Hot-Backup.
    Suppose i have 3 Online Redo Logs and i have put a tablespace in Backup Mode.
    So as a result whatever changes are made,Oracle will start generating redo for the entire block so as to avoid Fractured Blocks.
    Wat my Question is what if,while in the process of doing this all my Online Redo Logs files/members gets filled up how do then Oracle Manage to go ahead and keep recording the Transactions/Changes made to a Certain Block in the Tablespace.
    1.>Does Oracle Perform a Recovery from the Archived Redo Logs once the Tablespace taken out Backup Mode.
    2.>Or is there a reclamation/Re-sizing of On-line redo log file Space from other Segments.
    Thanks & Regards,
    Prosenjit Mukherjee.

    >
    I am not even sure that what the #2 means! Anways!
    Suppose i have 3 Online Redo Logs and i have put a tablespace in Backup Mode.It doesn't matter how many redo log groups you have and AFAIK this has no relation with a tablespace being in the backup mode whatsoever.
    So as a result whatever changes are made,Oracle will start generating redo for the entire block so as to avoid Fractured Blocks.Partially correct! The whole block gets copied only for the first time . For subsequent changes, only the change vectors go into the log buffer and then from there, to the redo log files. This is exactly equivalent to what does happen without a tablespace being not in the backup mode.
    Wat my Question is what if,while in the process of doing this all my Online Redo Logs files/members gets filled up how do then Oracle Manage to go ahead and keep recording the Transactions/Changes made to a Certain Block in the Tablespace.What does this mean exactly? If you fill up the redo logs, log switch will follow making teh LGWR switching from the current redo log group to the next, triggering checkpoint which would make the DBWR write the buffers to the datafile. I am not sure what is the confusion?
    Edit: I apologize , I read this point a little too fast! If all the log files are going to be filled up, database would be hung. There won't be any more transactions allowed as there is no place to write their change vectors anywhere. Sorry , I understood in the first time that you were talking about the standard log switching.
    1.>Does Oracle Perform a Recovery from the Archived Redo Logs once the Datafile is taken out Backup Mode.What recovery? Before the files go into the backup, there is a "global checkpoint" that is performed for them , pushing all of their buffers from the cache to them and then after the checkpoint is freezed for them, yet letting them do all the read/write operations. Once they come out of the backup mode, when the next time a checkpoint is performed, then their number gets synched with the rest of the database. From where the recovery comes into the picture here?
    2.>Or is there a reclamation/Re-sizing of On-line redo log file Space from other Segments.As I said before, I didn't understand at all what this point even means?
    HTH
    Aman....
    Edited by: Aman.... on Oct 24, 2009 9:19 PM added Edit

  • Iterator Interface.A question please......respond

    I am unable to grasp the meaning of the following below :
    As we all know,Interfaces have abstract methods,(ie methods that
    have no body) and any class that implements the Interface has to
    implement the methods defined in the interface.That is,write the body for those methods.
    So far so good.
    Now coming to Collections called Vector.
    We have the 'Iterator' interface implemented by the vector class.
    The Iterator interface has the methods hasNext(),next().
    and we have the following code in the our class which iterates thru'
    the vector:
    MyClass item;
    while(iter.hasNext())
    item = (MyClass)iter.next();
    // Do something here.....
    Now we are using the methods hasNext() and next() above.
    But as they belong to the Iterator interface,(which means they
    are basically methods with no implementations) then how is iteration
    possible? We havent defined anything in the hasNext() method or the next()
    so how does Java automatically start iteration
    Has any one understood my question?Arent hasNext() and next() supposed
    to be methods with no body???
    If I am saying iter.hasNext(),that means hasNext() has been defined
    somewhere to iterate thru the vector?
    I am just confused regarding this issue as to how is hasNext() and next()
    being implemented as I as the programmer have not implemented them
    in my code
    Please can some one answer my question?
    Regards
    Ajay

    Thanks for yr reply.
    So you mean to say the the Iterator methods hasNext()
    and next()
    are being implemented by the Vector class.right?Not exactly. The Vector class defines an inner class, and it is this class that implements the Iterator interface, and so these two methods. When you write code like
    Vector myVector = new Vector();
    // code to fill myVector...
    Iterator it = myVector.iterator();the call to the iterator() method tells myVector to give you an instance of this inner class. The Vector class itself doesn't implement next() or hasNext().
    Then why define an interface with these methods at
    all?
    Why not give concrete bodies to these methods and put
    them in
    the Object Class.If you did that, then all classes would inherit them - all classes would be iterators. That wouldn't make sense, though, as clearly not all classes are meant to be used to iterate over collections of objects.
    Iterator is an interface so that a consistent API can be defined for iteration. As iterators are used in lots of different places, it is very helpful to have all of them guaranteed to have next() and hasNext() methods (amongst others). It is also very helpful to be able to call the iterator() method on any Collection class and know that the object that is returned, regardless of its implementation, will be of type Iterator.
    Then we can call them polymorphically.???But that's what you're doing - Vector and ArrayList (for example) have different implementations of Iterator, but code that iterates over them doesn't need to know that. As both return objects that implement the Iterator interface, they are interchangeable; that's polymorphism at work.

  • Handling an external (Windows) process from Java.

    There is an example program in the 3rd edition of "The Java Language" by Gosling, et. al. The example is a simplified shell to handle an external executable. This is the code:
    public static Process userProg(String cmd) {
        Process child = Runtime.getRuntime().exec(cmd);
        plugTogether(System.in, child.getOutputStream());
        plugTogether(System.out, child.getInputStream());
        plugTogether(System.err, child.getErrorStream());
    }I have tried various means to make this skeleton work but to no avail. Is anybody aware of an example that would show how to not only startup an external executable but manage it with I/O? I have plenty of examples that startup something like:
    String[] cmdLine = {"ls", "-l" "dir"};
    Runtime.getRuntime().exec(cmdLine);
    ...But none of them control an external application like ftp that require an interactive session. If anyone can point me towards a book, website url, example here at Sun, I'd appreciate it but it needs to be an example that controls an external executable through input and output. Thanks.
    -John

    OK.
    This is not exactly an "example"; it is actual code from a production program. Names have been changed to protect proprietary info, so it is not clear that this will even compile. (Also: I would write this differently today, so please don't show this to anyone:-)
    Key limitations as an example:
    o The server is proprietary, so you can't see it.
    o The scripting language is proprietary, so you can't see it.
    This is a fragment of the interface between a large java application and a session-based server. The server was fed scripts - lines of interpreted code; the server executed the script. Key points:
    o If the script terminated with an "execute"command, then the server would hang around waiting for more scripts.
    o If the script terminated with an end, then the server process would exit.
    o What the server "said" in response was controlled by print statements in the script it was fed.
    Note the goofy print statements that allow my client to detect when the server completed a given transmission.
    import java.util.Enumeration;
    import java.util.Vector;
    import java.io.*;
    import Logger;
    * Provides data from proprietary server.
    public class ServerAccess {
          * Class to write script to server.
         private class Writer implements Runnable {
              Vector script;
              PrintStream p;
               * Constructor - establish a print stream to server.
              Writer(OutputStream s) {
                   p = new PrintStream(s);
               * Save the script to be written and start the writer.
              public void init( Vector script) {
                   this.script = script;
                   new Thread(this).start();
               * Thread to write script lines.
              public void run() {
                   for (Enumeration e = script.elements(); e.hasMoreElements(); ) {
                        p.println((String)e.nextElement());
                   // Make sure everything gets written out.
                   p.flush();
              public void finalize() {
                   // Shut down the print stream.
                   p.close();
         public boolean init() {
              // Access runtime so process can be created.
              Runtime r = Runtime.getRuntime();
              // Execute server.
              try {
                   p = r.exec("server.exe");
                   return true;
              catch(Exception e) {
                   Logger.logAlways("ServerAccess: Couldn't execute server. " + e.toString());
                   return false;
          * Terminate access to server.
         public void terminate() {
              Vector script = new Vector();
              script.add("end");
              // Write script to server process.
              Writer w = new Writer(p.getOutputStream());
              w.init(script);
              BufferedReader b = new BufferedReader(new InputStreamReader(p.getInputStream()));
              try {
                   String line;
                   while ((line = b.readLine()) != null) {
              catch (Exception e) {
                   Logger.logAlways("ServerAccess: Couldn't terminate server. " + e.toString());
              return;
          * Test method.
         public void runTest() {
              // Create test script.
              Vector script = new Vector();
              script.add(....);
              script.add("print END_OF_OUTPUT %RET");
              script.add("execute");
              // Write script to server process.
              Writer w = new Writer(p.getOutputStream());
              w.init(script);
              BufferedReader b = new BufferedReader(new InputStreamReader(p.getInputStream()));
              try {
                   String line;
                   while (true) {
                   line = b.readLine();
                   if (line.equals("END_OF_OUTPUT"))
                        break;
                        System.out.println(line);
              catch (Exception e) {
                   System.err.println(e.toString());
         * Test.
        public static void main(String[] args) {
            ServerAccess a = new ServerAccess();
              try {
                   a.init();
              catch(Exception e) {
                System.err.println(e.toString());
                return;
            a.runTest();
            a.terminate();
         // Object attributes.
        private Process p = null;
         String END_OF_PACKAGE = "END_OF_CONTENT";
         String END_OF_OUTPUT = "END_OF_OUTPUT";

  • Stumped on applet to servlet comminication

    Guys and Gals
    I am stumped, hope someone can help out.
    I have an applet talking to a servlet using some options sent through the URL (= doGet). The servlet queries a database, creates a vector with the results and serializes it back to the applet. No problem, works like a charm.
    Now I want to expand on this:
    - call the servlet using some parameters to determine what it should do (= doGet)
    - write a serialized vector of information from the applet to the servlet
    - the servlet queries a database based on what is in the vector
    - the servlet creates a HashMap with the results of the queries and sends the serialized HashMap back to the applet
    What happens is that I am getting an EOFException when the servlet attempts to read the Vector. The Vector is not empty.
    Am I missing something fundamental here, because it really has me stumped? I have not read anything prohibiting me to write a Vector and receive a HashTable but I am getting the impression that writing and then reading on the same servlet connection is screwing things up.
    Thanks
    Ben

    as far as I think, you should use doPost() as doGet() has restrictions over the amount of data sent. and use ObjectOutput/Input Streams to send and recieve Vector objects...

Maybe you are looking for

  • What is the best way to move and resize layers?

    When I click on a layer to move and resize it in Elements 8 in Windows 7, it disappears.  After I go to Edit/Undo, it reappears.  What should I do?

  • Deploying an ADF BC application in JDEv 10.1.2

    Hi: I have a webapplication developed with ADF BC, Struts, and JSP in JDev10.1.2. It consists of the normal model and view projects. It seems to work from local server. I would like to create the deployment profiles and deploy it on the test server.

  • Oracle E-Business Suite R12 with HACMP

    Hello, I'm planning to make a dtsirbuted installation of Oracle E-Business Suite R12 like the flollowing configuration : - Node 1:   Web and Forms - Node 2 : Concurrent Processing. The two nodes NODE1 and NODE2 are going to be in cluster HACMP, if No

  • Message Mapping - Dump

    I got the following dump, when I executed the Message Mapping. Eventhough I have fixed the problem, I am not quite sure to read the dump, i.e by reading the dump I was not sure which FIELD has caused the Dump. could some one help me , how I can read

  • TS1389 Repeated iTunes Authorization Request

    I moved our iTunes libraries from our old to new computer using the instructions on Apple.com.  However, iTunes continues to request that we authorize our new computer when trying to sync my wife's iPod to the new computer.  As such, iTunes will not