Is there a general purpose output stream class like in java?

Hi, I sometimes create tools (abap OO classes) which output characters, that I would like to store in any media (frontend file, server file, string variable, ftp, clipboard, etc.) This is easily done in java via the output stream classes.
Do you know if this kind of class exists? I saw some classes like that, but they are specialized, for example XML, SOAP. I look for non-specialized classes like in java.
Same question for input streams! (normally, we should deduct the input stream classes from the output stream classes)
Or did you develop yourself such input stream or output stream classes that you'd accept to share?
Thx a lot
sandra
Thx a lot!
Edited by: Matt on Nov 20, 2008 9:50 AM - Fixed the posting

Yes it exists, but in release 7.10 only. [ABAP Keyword Documentation u2192  ABAP - By Theme u2192  Process External Data u2192  Streaming|http://help.sap.com/abapdocu/en/ABENSTREAMING.htm]

Similar Messages

  • Input/output stream coupler (like a pipe, but reversed)

    I could write my own class but, for standardization purposes, I was wondering if there is anything in the Java API that does this:
    I have a Reader and a Writer and I want to connect them so that as soon as data is available from the Reader, it is written directly to the Writer.
    Reader>===>Writer
    as opposed to a pipe which looks loke
    Writer>===>Reader
    Is there such a class?

    I don't know of such a class, but you have the same API docs available to you as the rest of us. If you don't see it in java.io or java.nio or java.nio(.*), then it's not in the core API. At that point, I'd check sourceforge, jakarta, mindprod. After that, I might be inclined to post here, but I'd probably just say screw it and write my own.

  • Specifying output stream

    Hi,
    I have an client/server application that has System.out.println() command to display message in the dos shell. Now i want to add an option which makes it possible to display these messages in a textArea in a simple user interface.
    selecting this option will display messages in the test area. otherwise it is displayed in the dos shell using System.out.println().
    since i have to display messages many times i prefer not to use 'if' statement to verify which option the user has selected each time. ie.
    if(displayUserInterface)
    myTextArea.appendText(...);
    else
    System.out.println(...);
    is it possible to specify the output stream in the beggining and just provide the message i want to display further on? HOW?
    thanks and have fun

    thanks. it certainly helps and it is getting better.
    however i get error.
    it gives nullpointexception for super(null);
    Error msg;
    Exception in thread "main" java.lang.NullPointerException: Null outp
    ut stream
    at java.io.PrintStream.<init>(PrintStream.java:77)
    at java.io.PrintStream.<init>(PrintStream.java:59)
    at Core.TextAreaPrintStream.<init>(TextAreaPrintStream.java:
    14)
    Maybe we need to pass the OutputStream to printStream. but i dont know how to get output stream.
    the Code:
    import java.io.PrintStream;
    import java.io.*;
    import javax.swing.JTextArea;
    public class TextAreaPrintStream extends PrintStream
    private JTextArea ta;
    public TextAreaPrintStream(JTextArea ta)
    super(null);
    this.ta = ta;
    public void print(String s)
    ta.append(s);
    public void println(String s)
    ta.append(s);
    ta.append("\n");
    public void print(int i)
    ta.append(Integer.toString(i));

  • How many classes should a .java file contain?

    Are there any general guidelines on how many Java classes should be contained in a single .java file? I've been creating a new .java file for each class I write but see examples in Sun's Java tutorial where there are at least two classes in a single .java file. One such case is the TableDemo example at
    http://java.sun.com/docs/books/tutorial/uiswing/components/example-swing/TableDemo.java
    Thanks.

    The example you point to isn't really more the one class in one java file. It makes use of an inner class. An inner class is something different! As far as I understand it, it is mainly used to implement some behaviour (in this case AbstractTableModel behaviour). If the MyTableModel was in a separate class file, it couldn't access the variable of the main TableDemo class. So they use an inner class.
    So unless you need inner classes, this example is no reason to put more than one class in a .java file. In general, just put one class in a .java file. It's easier for everybody.

  • Is there a way to flush out a socket's output stream without...

    ...having to close it (the stream)?
    I'm trying to implement a keep-alive feature in a simple HTTP Server application. This is a draft of the code I have trouble with:
    ==========
    //'clientSocket' is the socket obtained by the 'serverSocket.accept()' method
    OutputStream out = clientSocket.getOutputStream();
    //'message' is a string to be sent to the client
    InputStream data = new ByteArrayInputStream(message.getBytes());
    byte[] buff = new byte[2048];
    while (true)
    int read = data.read(buff, 0, 2048);
    if (read <= 0)
    break;
    out.write(buff, 0, read);
    out.flush();
    ==========
    If I don't call 'out.close()', the data will not be sent to the client.
    If I call 'out.close()', the data will be sent, but the socket will be closed too, which I don't want to. I need to be able to reuse that socket .
    Is there any way to properly push out the data to the client without having to close the output stream?

    ...having to close it (the stream)?Yes. OutputStream.flush(). But if you're not using any kind of buffered writer/output stream you don't even have to do that.
    If I don't call 'out.close()', the data will not be sent to the client.Untrue. The client will read everything that has been written If you don't close the output stream, the client will never get the EOS indication (e.g. read() returning -1). So if your client is looping until that happens it will loop forever ...
    Your problem at the moment is at the reading end.

  • Questions about input/output streams

    In the following tutorial:
    http://chortle.ccsu.ctstateu.edu/CS151/Notes/chap85/ch85_10.html
    It mentions that some methods, such as write(), writeByte(), writeBytes(), and writeChar(), return the low eight bits of the argument to the output stream. I am a little unsure of what exactly that means, might somebody be able to clarify for me?
    In addition, I've been encountering the flush() method in some of the byte- and character-streaming objects that deal with buffers. What exactly is the flush() method's purpose, and when might it be used? Thank you.

    flush pushes the data out of the buffer. the write methods write to the buffer, when the buffer is full, it flushes itself (usually), or it could block the write methods (in theory). flush just lets you make sure that it's flushed.
    I'm not sure there's any reason to worry about high and low bytes in Java most of the time. I suppose, like anything, there's times you need to, but I can't think of any offhand.

  • How to read unix standrad pipe output stream

    I want to write some code that will read data from a standard solaris pipe output stream. Please help.
    For example
    I cat a file in a unix shell
    cat /etc/hosts
    The output of this file can be piped to another program and I want to write a piece of code that reads that piped data and puts it into a textArea.
    Thanks

    Here ya go bro.................
    This just checks if IO is coming in and if so prints it to the term, but
    you get the idea.
    There might be an better way but...........
    import java.io.*;
    class xxx
    public static void main(String args[])
    byte b[] = new byte[256];
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {
    if(System.in.available() > 0) {
    System.in.read(b);
    baos.write(b,0,256);
    System.out.println(baos.toString());
    else
    System.out.println("No pipe being layed");
    catch(Throwable t){}

  • Output Stream to JTextArea

    Hi there,
    I would like to have the output stream coming from the server to the client displayed on a JTextArea. However, because the coming file is a text document that had its file name passed as a local variable in the main method header with String a[ ], I am having difficulty setting this as the area text because of the incompatible types. This text prints on my command prompt window but I cannot figure out how to get this stream into the JTextArea. This is my code. The objective is to ask a file from the server and have the server send this file to the client so the client can then make changes and save.
    import java.io.*;
    import java.net.*;
    import javax.swing.JFrame;
    import javax.swing.JTextArea;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import javax.swing.JScrollPane;
    import javax.swing.JButton;
    import javax.swing.Box;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.FileNotFoundException;
    import java.io.PrintWriter;
    import java.util.Scanner;
    import java.util.Formatter;
    public class Client extends JFrame{
            public static JTextArea enterArea1;
            public static JTextArea enterArea2;
            public JButton change;
            public JButton save;
      public Client()
            super ("Client to Server");
            Box box = Box.createHorizontalBox();
            enterArea1 = new JTextArea(10, 15);
            enterArea1.setEditable (true);
            box.add (new JScrollPane (enterArea1));
            change = new JButton("Make Changes");
            box.add(change);
            change.addActionListener(
             new ActionListener()
                public void actionPerformed(ActionEvent event)
                Scanner console = new Scanner (System.in);
             System.out.print ("Input File: ");
             String inputFileName = console.next ();
             System.out.print ("Enter the text that you want to change");
             String inputText1 = console.next ();
             System.out.print ( "Output File: ");
             String outputFileName = console.next();
              try
              FileReader reader = new FileReader (inputFileName);
              Scanner in = new Scanner (reader);
              PrintWriter out = new PrintWriter (outputFileName);
                   String line1 = in.nextLine();
                   out.println( " " + inputText1 );
              out.close();
              catch (IOException exception)
              System.out.println ("Error processing file: " + exception);
            save = new JButton("Save to File");
            box.add(save);
            save.addActionListener(
             new ActionListener()
                public void actionPerformed(ActionEvent event)
                enterArea2.setText (enterArea1.getSelectedText());
            enterArea2 = new JTextArea (10, 15);
            enterArea2.setEditable (false);
            box.add (new JScrollPane (enterArea2));
            add (box);
      public static void main(String a[]) throws IOException {
            Socket sock;
            BufferedReader dis;
            PrintWriter dat;
            Client sendServer = new Client();
            sendServer.setSize (500, 200);
            sendServer.setVisible(true);
            sendServer.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
            sock = new Socket("127.0.0.1",4444);
            dis = new BufferedReader( new InputStreamReader(sock.getInputStream()) );
            dat = new PrintWriter( sock.getOutputStream() );
            dat.println(a[0]);
            dat.flush();
            enterArea1.setText(a[0]);
            PrintStream os = new PrintStream (new FileOutputStream ("out.txt"));
            String fromServer = dis.readLine();
            while (fromServer != null )
               System.out.println(fromServer);
               os.println(fromServer);
               fromServer = dis.readLine();
            sock.close();
    }

    I believe that the logic is to append the text to the JTextArea with something along the lines of this, but since String a[0] is passed in my void method, it is not accepted as a string anymore. The question then becomes how to create a variable that is referenced to the output text on the command window so that this variable can be used to append the same text to the JTextArea. I will appreciate any comments. Right now, it sees the String text as null.
    String text = dat.println(a[0]);
                          dat.flush();
            enterArea1.append(text]);

  • Separate thread for input stream and output stream.

    Hi Techies,
    In a socket connection, can we run the input stream and output stream in separate threads. actually in my case, the input stream will be getting the input regularly and output stream will send data very rare. so if i impelment them in one class then unless there is data to send output stream will be blocked. i was thinking to impelment both the streams in separate threads. is it a good way? so how to implement it. your guidance will be of great help.
    thanks in advance.

    JavaBreather wrote:
    Hi Techies,
    In a socket connection, can we run the input stream and output stream in separate threads.I would say this is the most common way of handling sockets and threads. esp pre-NIO.
    Iis it a good way? so how to implement it. your guidance will be of great help.Once you have a socket, create two threads, one which does the reading and one which does the writing.
    You could use BlockingQueues to abstract access to these threads. i.e. the reading thread reads something from the socket and adds it to the BlockingQueue. The writing thread take()s something froma second BlockingQueue and writes it to the Socket. This way you add things to write or get thing to process by looking at the BlockingQueues.

  • MultiThreading with Input and Output Streams

    Hi,
    I have a problem and I think it's because I'm not coding correctly. Please help me if you can understand what I'm doing wrong.
    I have a server that spawns a separate thread to go off and collect data from a serial port. It also waits to accept connections from any client and if a connection is made it will send that data to the clients connected.
    There is data constantly coming in through the serial port. It is output through a DataOutputStream so when the thread is created in the server, I pipe it into a DataInputStream. I do does because I want the server to then read in the data from the inputstream and then send it out to all my clients.
    So far, the way I have it set up seems to do this. But my problem occurs when I try to close a client connection. Instead of removing the socket connection it gives me an error that it can't send data to the client, but it shouldn't be sending data to the client because I just closed it. I realize this is probably because I'm still constantly receiving data from my inputstream and the connection was closed so it can't send that data to the client. I know I need to either close the stream or close my socket but I don't know where this needs to be done. I'm stuck on the correct way to fix this.
    My second problem is the initial connection made to receive data from the inputstream. This is probably because I'm not very familiar with how input/output streams work. But instead of just sending the client the current data being received in real time, it'll send all the data that's buffered in the inputstream. I don't want all the data that's been collecting to go to that first client. I only want the recent data that is coming through while the client is connected. Does this make sense? Because after I make a second client connection I don't have this problem because the InputStream is no longer buffered up. Should I be using something else besides the DataInputStream?
    I feel like I'm going about this the wrong way. Please advise. I'm shy about showing the code but I've included the bulk of it here in hopes that someone will see what I'm doing wrong. The only part that's left out is the thread that reads from the serial port. I don't seem to have any problems with that thread.
    Thanks,
    kim
    ===
    import java.io.*;
    import java.net.*;
    import javax.comm.*;
    import java.util.*;
    // DataServer waits for a client connection
    class DataServer
         static final int PORT = 7;
         // The ServerSocket to use for accepting new connections
         private ServerSocket ss;
         // A mapping from sockets to DataOutputStreams. This will
         // help us avoid from having to create a DataOutputStream each time
         // we want to write to a stream.
         private Hashtable outputStreams = new Hashtable();
         // The inputstream that will receive serial port data through a
         // piped inputstream
         public DataInputStream datalogger;
         // Constructor and while-accept loop all in one.
         public DataServer() throws IOException
              try {
                   // Creating pipe to convert the outputstream from the
                   // RS232 Thread to an inputstream for the server to read
                   PipedOutputStream pout = new PipedOutputStream();
                   PipedInputStream pin = new PipedInputStream(pout);
                   // The inputstream that will receive data from the RS232Thread
                   datalogger = new DataInputStream(pin);
                   // Spawn the thread that will read data through from
                   // the TINI serial port
                   new RS232Thread( pout ).start();
                   // Begin listening for connections and send data
                   listen();
              } catch (IOException ioe) {
                   System.out.println("Error >> DataServer::DataServer()");
                   System.out.println(ioe.getMessage());
                   ioe.printStackTrace();
              } finally {
                   try     {
                        System.out.println( "Closing >> DataServer::DataServer()" );
                        datalogger.close();
                   } catch (IOException i ) {
                        System.out.println( "Error2 >> DataServer::DataServer()" );
                        System.out.println(i); }
         private void listen() throws IOException
              // Create the ServerSocket
              ss = new ServerSocket( PORT );
              // Inform that the server is ready to go
              System.out.println( "Listening on " + ss );
              // Keep accepting connections forever
              while (true) {
                   // Grab the next incoming connection
                   Socket s = ss.accept();
                   // Inform that connection is made
                   System.out.println( "Connection from " + s );
                   // Create a DataOutputStream for writing data to the
                   // other side
                   DataOutputStream dout = new DataOutputStream( s.getOutputStream() );
                   // Save this stream so we don't need to make it again
                   outputStreams.put( s, dout );
                   // Create a new thread for this connection, and then foret
                   // about it
                   new ServerThread( this, s );
         // Get an enumeration of all the OutputStreams, one for each client
         // connected to the server
         Enumeration getOutputStreams() {
              return outputStreams.elements();
         // Send a message to all clients (utility routine)
         void sendToAll( byte[] b ) {
              // synchronize on this because another thread might be
              // calling removeConnection() and this would screw things up
              // while it walks through the list
              synchronized( outputStreams ) {
                   // For each client...
                   for (Enumeration e = getOutputStreams(); e.hasMoreElements();) {
                        // ... get the output stream ...
                        DataOutputStream dout = (DataOutputStream)e.nextElement();
                        // ... and send the message
                        try {          
                             dout.write( b );
                        } catch(IOException ie) {                     
                             System.out.println( "Error >> ServerThread::sendToAll()" );
                             System.out.println( ie );
         // remove a socket, and it's corresponding output stream, from the
         // list. This is usually called by a connection thread that has
         // discovered that the connection to the client is dead.
         void removeConnection( Socket s ) {
              // Synchronize so it doesn't mess up sendToAll() while it walks
              // down the list of all output streams
              synchronized( outputStreams ) {
                   // Inform about removal
                   System.out.println( "Removing connection to " + s );
                   // Remove if from our hastable/list
                   outputStreams.remove( s );
                   // Make sure it's closed
                   try {
                        s.close();
                   } catch( IOException ie ) {
                        System.out.println( "Error closing " + s );
                        ie.printStackTrace();
         // main - Opens a server socket and spins off a new thread each time
         // a new client connection is accepted on this socket.
         public static void main(String[] args) throws Exception
              System.out.println("Starting DataServer version 1.0 ...");
              try     
                   new DataServer();
              catch (IOException ioe)
                   System.out.println( "Error >> DataServer::main()" );
                   System.out.println(ioe.getMessage());
                   ioe.printStackTrace();
    class ServerThread extends Thread
         //The Server that spawned this thread
         private DataServer server;
         // The Socket connected to the client
         private Socket socket;
         //Constructor
         public ServerThread( DataServer server, Socket socket )
              // save the parameters
              this.server = server;
              this.socket = socket;
              // Start up the thread
              start();
         // This runs in a separate thread when start() is called in the
         // constructor
         public void run() {
              try {
                   // The inputstream receiving data from the global inputstream
                   // that is piped to the RS232 Thread
                   // ???? is this where i'm messing up ???
                   DataInputStream in = new DataInputStream( server.datalogger );
                   int num = 0;
                   byte[] d = new byte[1];
                   // read from the inputstream over and over, forever ...
                   while( ( num = in.read(d) ) > 0 ) {
                        // ... and have the server send it to all clients
                        server.sendToAll( d );               
              } catch (IOException ioe) {
                   System.out.println( "Error >> ServerThread::run()" );
                   System.out.println(ioe.getMessage());
                   ioe.printStackTrace();
              } finally {
                   // The connection is closed for one reason or another,
                   // so have the server dealing with it
                   System.out.println( "Closing" );
                   server.removeConnection( socket );

    A couple of things to note...
    First, you are looping infinitely in your server's constructor. Since the constructor is never completing, your server object is never completely constructed - this may cause indeterminate behaviour when you pass a reference to the server to another thread.
    Second, I would recommend fixing your issues by modifying your design somewhat. The design I would recommend (read: The design I would use) is:
    A server object, with a public listen method. The constructor spawns a thread to constantly read from the serial port and forward the data read back to the server, via a multicast (sendToAll) method.
    The listen method sets up a server socket to accept connections, and in a loop opens client sockets and stores them in a set.
    The multicast method iterates through the list of open client sockets, and for each in turn confirms that it is still open. If open, send the data down the socket's output stream; if closed, remove the socket from the set.
    Note that this design includes only two threads - the main thread listens for and accepts new socket connections, while the extra thread collects data from the serial port, multicasts it to all of the open sockets, and removes all of the closed sockets. If you require to perform any other communication with the sockets, it may be necessary to create a thread for those sockets, to facilitate reading from their input streams, but in the given design, this is not necessary.
    I hope this helps,
    -Troy

  • ObjectInput and Output streams

    Hi all,
    What is objectInput and Out Stream? For what purpose we r using it?
    regards,
    Mahe

    From the Standard Java API
    An ObjectInputStream deserializes primitive data and objects previously written using an ObjectOutputStream.
    ObjectOutputStream and ObjectInputStream can provide an application with persistent storage for graphs of objects when used with a FileOutputStream and FileInputStream respectively. ObjectInputStream is used to recover those objects previously serialized. Other uses include passing objects between hosts using a socket stream or for marshaling and unmarshaling arguments and parameters in a remote communication system.
    ObjectInputStream ensures that the types of all objects in the graph created from the stream match the classes present in the Java Virtual Machine. Classes are loaded as required using the standard mechanisms.
    Only objects that support the java.io.Serializable or java.io.Externalizable interface can be read from streams.
    The method readObject is used to read an object from the stream. Java's safe casting should be used to get the desired type. In Java, strings and arrays are objects and are treated as objects during serialization. When read they need to be cast to the expected type.
    Primitive data types can be read from the stream using the appropriate method on DataInput.
    The default deserialization mechanism for objects restores the contents of each field to the value and type it had when it was written. Fields declared as transient or static are ignored by the deserialization process. References to other objects cause those objects to be read from the stream as necessary. Graphs of objects are restored correctly using a reference sharing mechanism. New objects are always allocated when deserializing, which prevents existing objects from being overwritten.
    Reading an object is analogous to running the constructors of a new object. Memory is allocated for the object and initialized to zero (NULL). No-arg constructors are invoked for the non-serializable classes and then the fields of the serializable classes are restored from the stream starting with the serializable class closest to java.lang.object and finishing with the object's most specific class.
    For example to read from a stream as written by the example in ObjectOutputStream:
         FileInputStream fis = new FileInputStream("t.tmp");
         ObjectInputStream ois = new ObjectInputStream(fis);
         int i = ois.readInt();
         String today = (String) ois.readObject();
         Date date = (Date) ois.readObject();
         ois.close();
    Classes control how they are serialized by implementing either the java.io.Serializable or java.io.Externalizable interfaces.
    Implementing the Serializable interface allows object serialization to save and restore the entire state of the object and it allows classes to evolve between the time the stream is written and the time it is read. It automatically traverses references between objects, saving and restoring entire graphs.
    Serializable classes that require special handling during the serialization and deserialization process should implement the following methods:
    private void writeObject(java.io.ObjectOutputStream stream)
    throws IOException;
    private void readObject(java.io.ObjectInputStream stream)
    throws IOException, ClassNotFoundException;
    private void readObjectNoData()
    throws ObjectStreamException;
    The readObject method is responsible for reading and restoring the state of the object for its particular class using data written to the stream by the corresponding writeObject method. The method does not need to concern itself with the state belonging to its superclasses or subclasses. State is restored by reading data from the ObjectInputStream for the individual fields and making assignments to the appropriate fields of the object. Reading primitive data types is supported by DataInput.
    Any attempt to read object data which exceeds the boundaries of the custom data written by the corresponding writeObject method will cause an OptionalDataException to be thrown with an eof field value of true. Non-object reads which exceed the end of the allotted data will reflect the end of data in the same way that they would indicate the end of the stream: bytewise reads will return -1 as the byte read or number of bytes read, and primitive reads will throw EOFExceptions. If there is no corresponding writeObject method, then the end of default serialized data marks the end of the allotted data.
    Primitive and object read calls issued from within a readExternal method behave in the same manner--if the stream is already positioned at the end of data written by the corresponding writeExternal method, object reads will throw OptionalDataExceptions with eof set to true, bytewise reads will return -1, and primitive reads will throw EOFExceptions. Note that this behavior does not hold for streams written with the old ObjectStreamConstants.PROTOCOL_VERSION_1 protocol, in which the end of data written by writeExternal methods is not demarcated, and hence cannot be detected.
    The readObjectNoData method is responsible for initializing the state of the object for its particular class in the event that the serialization stream does not list the given class as a superclass of the object being deserialized. This may occur in cases where the receiving party uses a different version of the deserialized instance's class than the sending party, and the receiver's version extends classes that are not extended by the sender's version. This may also occur if the serialization stream has been tampered; hence, readObjectNoData is useful for initializing deserialized objects properly despite a "hostile" or incomplete source stream.
    Serialization does not read or assign values to the fields of any object that does not implement the java.io.Serializable interface. Subclasses of Objects that are not serializable can be serializable. In this case the non-serializable class must have a no-arg constructor to allow its fields to be initialized. In this case it is the responsibility of the subclass to save and restore the state of the non-serializable class. It is frequently the case that the fields of that class are accessible (public, package, or protected) or that there are get and set methods that can be used to restore the state.
    Any exception that occurs while deserializing an object will be caught by the ObjectInputStream and abort the reading process.
    Implementing the Externalizable interface allows the object to assume complete control over the contents and format of the object's serialized form. The methods of the Externalizable interface, writeExternal and readExternal, are called to save and restore the objects state. When implemented by a class they can write and read their own state using all of the methods of ObjectOutput and ObjectInput. It is the responsibility of the objects to handle any versioning that occurs.
    Edited by: pgeuens on Dec 26, 2007 1:50 PM

  • Reading native process standard output stream with ProcessBuilder

    Hi,
    I'd like to launch an native process (windows application) which writes on standard output during its running.
    I'd like to view my application output on a JTextArea on my Java frame (Swing). But I do get all process output
    on text area only when the process is finished (it takes about 20 seconds to complete). My external process is
    launched by using a ProcessBuilder object.
    Here is my code snippet with overridden doInBackground() and process() methods of ProcessBuilder class:
    @Override
    public String doInBackground() {
    jbUpgrade.setEnabled(false);
    ProcessBuilder pb = new ProcessBuilder();
    paramFileName = jtfParameter.getText();
    command = "upgrade";
    try {
    if (!(paramFileName.equals(""))) {
    pb.command(command, jtfRBF.getText(), jtfBaseAddress.getText(), "-param", paramFileName);
    } else {
    pb.command(command, jtfRBF.getText(), jtfBaseAddress.getText());
    pb.directory(new File("."));
    pb.redirectErrorStream(false);
    p = pb.start();
    try {
    InputStream is = p.getInputStream();
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr);
    String line;
    jtaOutput.setText("");
    while ((line = br.readLine()) != null) {
    publish(line);
    } catch (IOException ex) {
    Logger.getLogger(CVUpgradeFrame.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
    Logger.getLogger(CVUpgradeFrame.class.getName()).log(Level.SEVERE, null, ex);
    jtaOutput.setText("");
    jtaOutput.setLineWrap(true);
    jtaOutput.append("Cannot execute requested commmad:\n" + pb.command());
    jtaOutput.append("\n");
    jtaOutput.setLineWrap(false);
    return "done";
    @Override
    protected void process(List<String> line) {
    jtaOutput.setLineWrap(true);
    Iterator<String> it = line.iterator();
    while (it.hasNext()) {
    jtaOutput.append(it.next() + newline);
    jtaOutput.repaint();
    //Make sure the new text is visible, even if there
    //was a selection in the text area.
    jtaOutput.setCaretPosition(jtaOutput.getDocument().getLength());
    How can I get my process output stream updated while it is running and not only when finished?
    Thanks,
    jluke

    1) Read the 4 sections of http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html and implement the recommendations. Although it is concerned with Runtime.exec() the recommendations still apply to Process generated by ProcessBuilder.
    2) Read about concurrency in Swing - http://java.sun.com/docs/books/tutorial/uiswing/concurrency/ .
    3) Use SwingUtilities.invokeLater() to update your GUI.

  • Store Output Stream into String

    Hello
    I want to store my out put stream in to string so that i can use it latter.
    out.println("Nilesh patel");
    out.println("[email protected]");
    out.println("Ahmedabad");
    it is "Nilesh patel [email protected] Ahmedabad" but i want to store into string like
    String tmp = out.toString();
    it is return the hash code of out object how can i store this value in String variable?

    To me, the most elegant way to do this would be with a Servlet Filter.
    You use a ResponseWrapper to create a "BufferedResponse" object, and pass that down to the next JSP/Servlet. Basically you have to override methods such as getWriter(), getOutputStream()...
    The JSP/servlet works as normal, but any calls to out.println() can be under your control.
    This simple class might help:
    public class RedirectingServletResponse extends HttpServletResponseWrapper {
        RedirectServletStream out;
         * @param arg0
        public RedirectingServletResponse(HttpServletResponse response, OutputStream out) {
            super(response);
            this.out = new RedirectServletStream(out);
        /* (non-Javadoc)
         * @see javax.servlet.ServletResponse#flushBuffer()
        public void flushBuffer() throws IOException {
            out.flush();
        /* (non-Javadoc)
         * @see javax.servlet.ServletResponse#getOutputStream()
        public ServletOutputStream getOutputStream() throws IOException {
            return out;
        /* (non-Javadoc)
         * @see javax.servlet.ServletResponse#getWriter()
        public PrintWriter getWriter() throws IOException {
            return new PrintWriter(out);
        private static class RedirectServletStream extends ServletOutputStream {
            OutputStream out;
            RedirectServletStream(OutputStream out) {
                this.out = out;
            public void write(int param) throws java.io.IOException {
                out.write(param);
    }You then use it something like this:
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) {
      // create an output stream - to file, to memory...
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      // create the "dummy" response object
      RedirectingServletResponse dummyResponse = new RedirectingServletResponse(response, out);
      // pass it on to the next level:
      chain.doFilter(request, dummyResponse);
      // at this point the OutputStream has had the response written into it.
      byte[] result = out.getByteArray();
      // now you can do with it what you will.
    }There is probably a better way - providing response that will write any output to two output streams - the original and an alternative one (file) would be a good option.
    Hope this helps,
    evnafets

  • Using cRIO chassis slots for general-purpose

    hi,
    i have cRIO 9004 and cRIO 9103 chassis, labview 2011...
    as i know, cRIO chassis controls its slots if there present any module or not.. if detect anyone, read EEPROM and so on..
    but how can i control cRIO chassis slots for my own general-purpose without any module...
    when i create projects, it just shows me as chassis I/O
    * chassis Temperature
    * FPGA LED
    * Scan Clock
    * Sleep
    * system reset
    i couldn't write anything from chassis slots and see on oscilloscope screen, (for example: using as analog or digital output) ... 
    Davut..
    Solved!
    Go to Solution.

    thanks for your reply
    in fact i have...
    -module development kit 2.0
    -compactRIO module support 4.0.1
    -NIRIO 4.0
    i know which pins i can use for DIO or etc.. 
    the point is, i haven't thought that it is not possible without hardware.. i read the manuals but couldn't create all structure in my mind..
    So, as i understand from your message, i have some programs but it s not possible to controlling chassis slots without hardware.. am i right?

  • Servlet Output Streams and clearing

    I am using servlets, and I want to be able to print something repeatedly. Well, that's not exactly true: I can print something repeatedly. Using a ServletOutputStream, it doesn't seem possible to clear what has already been written. Here's the code:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.io.*;
    public class AlwaysTime extends HttpServlet {
         public void doPost(HttpServletRequest req, HttpServletResponse res)                throws ServletException, IOException {
              HttpServletResponse oldRes = res;
              Date now = new Date();
              res.setContentType("text/html");
              ServletOutputStream out = res.getOutputStream();
              out.println("<html>");
              out.println("<head>");
              out.println("<title>Clock</title>");
              out.println("</head>");
              out.println("<body>");
              out.println("<h1 align=\"Center\">");
              out.println(now.toString());
              out.println("</h1>");
              out.println("</body>");
              out.println("</html>");
              try {
                 Thread.sleep(1000);
              } catch (InterruptedException ie) {}
              // Do nothing: wait for 1 second.
              doPost(req, oldRes);
         public void doGet(HttpServletRequest req, HttpServletResponse res)
              throws ServletException, IOException {
              doPost(req, res);
    }This code prints the time every second, but I want to clear the previous output stream. I thought the code shown above would work, but of course, oldRes points to the same object as res. But I don't know how to clear an output stream, so that it is completely empty. Instead, each of the new lines are appended to the same output stream.
    This doesn't only apply to servlet output streams: is there some way to clear the System output stream, for instance?
    But mainly the servlet output stream ...

    You would not want to use HTTP for this type of functionality. HTTP is known as a 'stateless' protocol that simply returns one exact response for each request. So, there is not way to 'clear' the stream (technically, you would not do so for 'normal' streams either, but when you add HTTP into the mix, the task is definitely not possible).
    You could implement the above using a RSS feed, or by using HTTP meta-refresh tags on the page itself ot resubmit the requests every second (though this would be inefficient). An applet would also do the task.
    - Saish

Maybe you are looking for

  • Preview has trouble new pdf file

    I have never had problems with Preview and PDF's, but today I tried to open a PDF file I downloaded and it opens but some of the pages are not displaying right. I downloaded it again and the same thing happens. If I open it with Adobe Reader 9.0 it d

  • REP-56092 WHEN RUN REPORT IN WEB LAYOUT

    I have installed report 9iDS and can run report in paper layout without any problem. However , when I press "Run Web Layout" button , I get message rep-56092 NO CLASS DEFINED FOR DESTINATION TYPE SCREEN WHEN RUN WEBLAYOUT. Do anybody has idea why thi

  • ATV - File format not recognized!

    Hi. Can anyone help.  Mt ATV has started saying the "file format is not recognised" for the movies I have on it.  The movies work find in Itunes but for some of them (only) the ATV refuses to play them....  help please?

  • Installed OBIEE on laptop without loopback adapter

    Hello there I have installed OBIEE 11.1.1.5 on my personal laptop which was on DHCP network and connected to Wi-Fi. However prior to installation i did not install & configure the loopback adapter. Now when i try to go out of my Wi-Fi network and its

  • Wireless Configuration in MAC OS X 10.6.3

    Hi We are using using PEAP with MSCHAPv2 for our wireless authentication 802.1x All windows systems are working fine with this. (as we are pushing wireless settings through group policy) Now we want to configure same in MAC OS systems. We already add