ComboBoxs outputting to a string

Hi in this code I've created four comboBoxs and the selections from the comboBoxs then build a string and outputs it in label6. It does this ok but when the user changes a value in one of the comboBoxs the string does not update. I'm just not sure how to do it? Can anyone help?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class Menu extends JPanel implements ActionListener
private JButton Reset;
private JButton Run;
private JLabel label1;
private JLabel label2;
private JLabel label3;
private JLabel label4;
private JLabel label5;
private JLabel label6;
private JLabel label7;
private JComboBox EnsembleSize = null;
private JComboBox Randomize;
private JComboBox baseModel = null;
private JComboBox dataChoices;
final static int START_INDEX = 0;
private String Configs;
private String[] baseModelRun;
private String[] dataRun;
private String[] EnsembleSizeRun;
private String[] RandomizeRun;
public Menu()
     constructComboBoxs();
constructComponents();
addComponents();
positionComponents();
//Set ActionListeners
Run.setActionCommand("RunButton");
Run.addActionListener(this);
Reset.setActionCommand("ResetButton");
Reset.addActionListener(this);
EnsembleSize.setActionCommand("ensemble");
EnsembleSize.addActionListener(this);
     public void actionPerformed(ActionEvent e)
          if (e.getActionCommand().equals("RunButton"))
               label5.setText("<html><font color=red>RUNNING NOW!!!</font></html>");
     //label6.setText(baseModelRun[baseModel.getSelectedIndex()]);
     label6.setText("Configs: " + Configs);
                    EnsembleSize.setEnabled(false);
                    baseModel.setEnabled(false);
                    Randomize.setEnabled(false);
                    dataChoices.setEnabled(false);
          else if(e.getActionCommand().equals("ResetButton"))
               Toolkit.getDefaultToolkit().beep();
     label5.setText("");
     label6.setText("Configs: ");
                    EnsembleSize.setEnabled(true);
                    baseModel.setEnabled(true);
                    Randomize.setEnabled(true);
                    dataChoices.setEnabled(true);
          EnsembleSize.setSelectedIndex(0);
          baseModel.setSelectedIndex(0);
          Randomize.setSelectedIndex(0);
          dataChoices.setSelectedIndex(0);
     /*else if(e.getActionCommand().equals("ensemble"))
          //label6.setText(EnsembleSizeRun[EnsembleSize.getSelectedIndex()]);
     String petName = (String)EnsembleSize.getSelectedItem();
     label6.setText(petName);
          void constructComboBoxs()
          //construct preComponents with arrays for comboBoxs
          String[] EnsembleSizeItems = {" x 1", " x 5", " x 10"};
          String[] RandomizeItems = {"Compare all methods"," Random Features", " Random Sampling", " Randomise Outputs"};
          String[] baseModelItems = {"Nearest Neighbour", "Linear Regression", "M5P Tree"};
          String[] DataItems = {"autoprice", "BreastTumor", "cholesterol", "housing","pollution"};
     String[] EnsembleSizeRun = {" -E 1 -N 5", " -E 5 -N 5", " -E 10 -N 5"};
          String[] RandomizeRun = {""," -S 0"," -S 1"," -S 2"};
     String[] baseModelRun = {"research.predictors.knn",
                                   "weka.classifiers.LinearRegression",
                                   "weka.classifiers.trees.M5P"};
     String[] dataRun = {"-c 16 -t \"C://ensembleResearchNew//data//autoprice.arff\"",
     "-c 10 -t \"C://ensembleResearchNew//data//BreastTumor.arff\"",
     "-c 14 -t \"C://ensembleResearchNew//data//cholesterol.arff\"",
     "-c 14 -t \"C://ensembleResearchNew//data//housing.arff\"",
     "-c 16 -t \"C://ensembleResearchNew//data//pollution.arff\""};
     //construct components
     baseModel = new JComboBox(baseModelItems);
     baseModel.setSelectedIndex(START_INDEX);
     EnsembleSize = new JComboBox (EnsembleSizeItems);
     EnsembleSize.setSelectedIndex(0);
     Randomize = new JComboBox (RandomizeItems);
     Randomize.setSelectedIndex(2);
               dataChoices = new JComboBox (DataItems);
     dataChoices.setSelectedIndex(0);
     //constructs configurations for running experiment
               Configs = (baseModelRun[baseModel.getSelectedIndex()] + " "
          + dataRun[dataChoices.getSelectedIndex()]
          + EnsembleSizeRun[EnsembleSize.getSelectedIndex()]
          + RandomizeRun[Randomize.getSelectedIndex()]);
          void constructComponents()
               //constructs labels
     label1 = new JLabel ("<html><font color=red size=10>MAIN MENU</font></html>");
     label2 = new JLabel ("Select size of ensemble:");
     label3 = new JLabel ("Select a Base Model:");
     label4 = new JLabel ("Select randomising method:");
     label5 = new JLabel ();
     label6 = new JLabel ();
     label7 = new JLabel ("Select data set:");
     //constructs buttons
     Reset = new JButton ("Reset");
     Run = new JButton ("Run!");                
     void addComponents()
     //adds comboBoxs
     add (EnsembleSize);
     add (Randomize);
     add (baseModel);
     add (dataChoices);
     //adds labels
     add (label1);
     add (label2);
     add (label3);
     add (label4);
     add (label5);
     add (label6);
     add (label7);
     //add buttons
     add (Reset);
     add (Run);
     //add message hints to buttons
     Run.setToolTipText("Press this button to run experiment");
     Reset.setToolTipText("Press this button to reset all options for experiment");
          void positionComponents()
     //Sets size and set layout for panel
     setPreferredSize (new Dimension (420, 400));
     setLayout (null);
     sets component bounds for Absolute Positioning of components
     * setup guide = name.setBounds(x1, y, x2, height) *
     //sets positions for combo boxes
     EnsembleSize.setBounds (225, 60, 60, 25);
     Randomize.setBounds (225, 170, 150, 25);
     baseModel.setBounds (225, 115, 137, 25);
     dataChoices.setBounds (225, 225, 150, 25);
     //sets positions for labels on panel
     label1.setBounds (100, 0, 300, 40);
     label2.setBounds (65, 60, 145, 25);
     label3.setBounds (80, 114, 122, 25);
     label4.setBounds (42, 170, 166, 25);
     label5.setBounds (175, 350, 100, 25);//RUNNING NOW!!!
     label6.setBounds (10, 275, 700, 25);//configs
     label7.setBounds (110, 225, 150, 25);
     //sets positions for buttons on panel
     Reset.setBounds (125, 315, 100, 20);
     Run.setBounds (215, 315, 100, 20);
     public static void main(String[] args)
          JFrame.setDefaultLookAndFeelDecorated(true);
     JFrame frame = new JFrame ("JPanel Preview");
     frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
     frame.getContentPane().add (new Menu());
     frame.pack();
     frame.setVisible (true);
}

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class Menu extends JPanel implements ActionListener
     private JButton Reset;
     private JButton Run;
     private JLabel label1;
     private JLabel label2;
     private JLabel label3;
     private JLabel label4;
     private JLabel label5;
     private JLabel label6;
     private JLabel label7;
     private JComboBox EnsembleSize = null;
     private JComboBox Randomize;
     private JComboBox baseModel = null;
     private JComboBox dataChoices;
     final static int START_INDEX = 0;
     private String Configs;
     private String[] baseModelRun;
     private String[] dataRun;
     private String[] EnsembleSizeRun;
     private String[] RandomizeRun;
     public Menu()
          constructComboBoxs();
          constructComponents();
          addComponents();
          positionComponents();
//          Set ActionListeners
          Run.setActionCommand("RunButton");
          Run.addActionListener(this);
          Reset.setActionCommand("ResetButton");
          Reset.addActionListener(this);
          EnsembleSize.setActionCommand("ensemble");
          EnsembleSize.addActionListener(this);
          baseModel.setActionCommand("base");
          baseModel.addActionListener(this);
          Randomize.setActionCommand("random");
          Randomize.addActionListener(this);
          dataChoices.setActionCommand("data");
          dataChoices.addActionListener(this);
     public void actionPerformed(ActionEvent e)
          if (e.getActionCommand().equals("RunButton"))
               label5.setText("<html><font color=red>RUNNING NOW!!!</font></html>");
               label6.setText("Configs: "+EnsembleSize.getItemAt(EnsembleSize.getSelectedIndex())
          + " - " + baseModel.getItemAt(baseModel.getSelectedIndex()) + " - "
          + Randomize.getItemAt(Randomize.getSelectedIndex()) + " - "
          + dataChoices.getItemAt(dataChoices.getSelectedIndex()));
               EnsembleSize.setEnabled(false);
               baseModel.setEnabled(false);
               Randomize.setEnabled(false);
               dataChoices.setEnabled(false);
          else if(e.getActionCommand().equals("ResetButton"))
               Toolkit.getDefaultToolkit().beep();
               label5.setText("");
               label6.setText("Configs: ");
               EnsembleSize.setEnabled(true);
               baseModel.setEnabled(true);
               Randomize.setEnabled(true);
               dataChoices.setEnabled(true);
               EnsembleSize.setSelectedIndex(0);
               baseModel.setSelectedIndex(0);
               Randomize.setSelectedIndex(0);
               dataChoices.setSelectedIndex(0);
          else if(e.getActionCommand().equals("ensemble"))
          label6.setText("Configs: " + baseModel.getItemAt(baseModel.getSelectedIndex()) + " - "
                                             + Randomize.getItemAt(Randomize.getSelectedIndex()) + " - "
                                             + dataChoices.getItemAt(dataChoices.getSelectedIndex()) + " - "
                                             + EnsembleSize.getItemAt(EnsembleSize.getSelectedIndex()) );
          else if(e.getActionCommand().equals("base"))
          label6.setText("Configs: " + baseModel.getItemAt(baseModel.getSelectedIndex()) + " - "
                                             + Randomize.getItemAt(Randomize.getSelectedIndex()) + " - "
                                             + dataChoices.getItemAt(dataChoices.getSelectedIndex()) + " - "
                                             + EnsembleSize.getItemAt(EnsembleSize.getSelectedIndex()) );
          else if(e.getActionCommand().equals("random"))
          label6.setText("Configs: " + baseModel.getItemAt(baseModel.getSelectedIndex()) + " - "
                                             + Randomize.getItemAt(Randomize.getSelectedIndex()) + " - "
                                             + dataChoices.getItemAt(dataChoices.getSelectedIndex()) + " - "
                                             + EnsembleSize.getItemAt(EnsembleSize.getSelectedIndex()) );
          else if(e.getActionCommand().equals("data"))
          label6.setText("Configs: " + baseModel.getItemAt(baseModel.getSelectedIndex()) + " - "
                                             + Randomize.getItemAt(Randomize.getSelectedIndex()) + " - "
                                             + dataChoices.getItemAt(dataChoices.getSelectedIndex()) + " - "
                                             + EnsembleSize.getItemAt(EnsembleSize.getSelectedIndex()) );
     void constructComboBoxs()
//          construct preComponents with arrays for comboBoxs
          String[] EnsembleSizeItems = {" x 1", " x 5", " x 10"};
          String[] RandomizeItems = {"Compare all methods"," Random Features", " Random Sampling", " Randomise Outputs"};
          String[] baseModelItems = {"Nearest Neighbour", "Linear Regression", "M5P Tree"};
          String[] DataItems = {"autoprice", "BreastTumor", "cholesterol", "housing","pollution"};
          String[] EnsembleSizeRun = {" -E 1 -N 5", " -E 5 -N 5", " -E 10 -N 5"};
          String[] RandomizeRun = {""," -S 0"," -S 1"," -S 2"};
          String[] baseModelRun = {"research.predictors.knn",
                    "weka.classifiers.LinearRegression",
          "weka.classifiers.trees.M5P"};
          String[] dataRun = {"-c 16 -t \"C://ensembleResearchNew//data//autoprice.arff\"",
                    "-c 10 -t \"C://ensembleResearchNew//data//BreastTumor.arff\"",
                    "-c 14 -t \"C://ensembleResearchNew//data//cholesterol.arff\"",
                    "-c 14 -t \"C://ensembleResearchNew//data//housing.arff\"",
          "-c 16 -t \"C://ensembleResearchNew//data//pollution.arff\""};
//          construct components
          baseModel = new JComboBox(baseModelItems);
          baseModel.setSelectedIndex(START_INDEX);
          EnsembleSize = new JComboBox (EnsembleSizeItems);
          EnsembleSize.setSelectedIndex(0);
          Randomize = new JComboBox (RandomizeItems);
          Randomize.setSelectedIndex(2);
          dataChoices = new JComboBox (DataItems);
          dataChoices.setSelectedIndex(0);
//          constructs configurations for running experiment
          Configs = (baseModelRun[baseModel.getSelectedIndex()] + " "
                    + dataRun[dataChoices.getSelectedIndex()]
                    + EnsembleSizeRun[EnsembleSize.getSelectedIndex()]
                    + RandomizeRun[Randomize.getSelectedIndex()]);
     void constructComponents()
//          constructs labels
          label1 = new JLabel ("<html><font color=red size=10>MAIN MENU</font></html>");
          label2 = new JLabel ("Select size of ensemble:");
          label3 = new JLabel ("Select a Base Model:");
          label4 = new JLabel ("Select randomising method:");
          label5 = new JLabel ();
          label6 = new JLabel ();
          label7 = new JLabel ("Select data set:");
//          constructs buttons
          Reset = new JButton ("Reset");
          Run = new JButton ("Run!");
     void addComponents()
//adds comboBoxs
          add (EnsembleSize);
          add (Randomize);
          add (baseModel);
          add (dataChoices);
//adds labels
          add (label1);
          add (label2);
          add (label3);
          add (label4);
          add (label5);
          add (label6);
          add (label7);
//add buttons
          add (Reset);
          add (Run);
//add message hints to buttons
          Run.setToolTipText("Press this button to run experiment");
          Reset.setToolTipText("Press this button to reset all options for experiment");
     void positionComponents()
//          Sets size and set layout for panel
          setPreferredSize (new Dimension (420, 400));
          setLayout (null);
          sets component bounds for Absolute Positioning of components
          * setup guide = name.setBounds(x1, y, x2, height) *
//sets positions for combo boxes
          EnsembleSize.setBounds (225, 60, 60, 25);
          Randomize.setBounds (225, 170, 150, 25);
          baseModel.setBounds (225, 115, 137, 25);
          dataChoices.setBounds (225, 225, 150, 25);
//sets positions for labels on panel
          label1.setBounds (100, 0, 300, 40);
          label2.setBounds (65, 60, 145, 25);
          label3.setBounds (80, 114, 122, 25);
          label4.setBounds (42, 170, 166, 25);
          label5.setBounds (175, 350, 100, 25);//RUNNING NOW!!!
          label6.setBounds (10, 275, 700, 25);//configs
          label7.setBounds (110, 225, 150, 25);
//sets positions for buttons on panel
          Reset.setBounds (125, 315, 100, 20);
          Run.setBounds (215, 315, 100, 20);
     public static void main(String[] args)
          JFrame.setDefaultLookAndFeelDecorated(true);
          JFrame frame = new JFrame ("JPanel Preview");
          frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
          frame.getContentPane().add (new Menu());
          frame.pack();
          frame.setVisible (true);
Right here is my updated code at present when run button is clicked outputs all selected values to label at bottom of GUI. But I need it to output the relevant value from another array
say if 2nd item 2x 5" EnsembleSize ComboBox is selected
I want it not to output that to label but the 2nd item in the array EnsembleSizeRun so instead it should output "-E 5 - N 5"
If we can get that one to do that then it will be very easy to do the same for all the others, Can anyone get that to work?

Similar Messages

  • PLSQL - Output a long string to screen

    I am trying to create an XML file, but I don't have FTP access on the server, only read rights.
    So I need to output a long string on the screen.
    By using the
    DBMS_OUTPUT.PUT_LINE ('<Environment> ' || long_string_01 || long_string_02 || '</Environment>');
    I get the 255 buffer error.
    Whats the easiest way around it?
    Thanks in advance everyone!
    Edited by: 866635 on Aug 5, 2011 5:16 AM

    Hi,
    I agree with Mr Robertson.
    SQL> SET SERVEROUTPUT ON SIZE 1000000
    SQL> SET LONG 1000000000 LONGC 1000000000
    SQL> set pagesize 200
    SQL> select TO_CLOB('When I use a LONG setting smaller than the length of the TEXT column,
      2  I got it truncated. When I use a huge LONG setting but a LONGCHUNKSIZE setting smaller than the
    length of the TEXT column, I got it wrapped. When both are huge, it seems I am getting the expectin
    g result. So why not setting SET LONG 2000000000 LONGC 2000000000 in your login.sql ?
      3  When I use a LONG setting smaller than the length of the TEXT column, I got it truncated.
      4  When I use a huge LONG setting but a LONGCHUNKSIZE setting smaller than the length of the
      5   TEXT column, I got it wrapped. When both are huge, it seems I am getting the expecting
      6   result. So why not setting SET LONG 2000000000 LONGC 2000000000 in your login.sql ?
      7  When I use a LONG setting smaller than the length of the TEXT column, I got it truncated.
      8  When I use a LONG setting smaller than the length of the TEXT column,
      9  I got it truncated. When I use a huge LONG setting but a LONGCHUNKSIZE setting smaller than the
    length of the TEXT column, I got it wrapped. When both are huge, it seems I am getting the expectin
    g result. So why not setting SET LONG 2000000000 LONGC 2000000000 in your login.sql ?
    10  When I use a LONG setting smaller than the length of the TEXT column, I got it truncated.
    11  When I use a huge LONG setting but a LONGCHUNKSIZE setting smaller than the length of the
    12   TEXT column, I got it wrapped. When both are huge, it seems I am getting the expecting
    13   result. So why not setting SET LONG 2000000000 LONGC 2000000000 in your login.sql ?
    14  When I use a LONG setting smaller than the length of the TEXT column, I got it truncated.
    15  When I use a LONG setting smaller than the length of the TEXT column,
    16  I got it truncated. When I use a huge LONG setting but a LONGCHUNKSIZE setting smaller than the
    length of the TEXT column, I got it wrapped. When both are huge, it seems I am getting the expectin
    g result. So why not setting SET LONG 2000000000 LONGC 2000000000 in your login.sql ?
    17  When I use a LONG setting smaller than the length of the TEXT column, I got it truncated.
    18  When I use a huge LONG setting but a LONGCHUNKSIZE setting smaller than the length of the
    19   TEXT column, I got it wrapped. When both are huge, it seems I am getting the expecting
    20   result. So why not setting SET LONG 2000000000 LONGC 2000000000 in your login.sql ?
    21  When I use a LONG setting smaller than the length of the TEXT column, I got it truncated.
    22  When I use a LONG setting smaller than the length of the TEXT column,
    23  I got it truncated. When I use a huge LONG setting but a LONGCHUNKSIZE setting smaller than the
    length of the TEXT column, I got it wrapped. When both are huge, it seems I am getting the expectin
    g result. So why not setting SET LONG 2000000000 LONGC 2000000000 in your login.sql ?
    24  When I use a LONG setting smaller than the length of the TEXT column, I got it truncated.
    25  When I use a huge LONG setting but a LONGCHUNKSIZE setting smaller than the length of the
    26   TEXT column, I got it wrapped. When both are huge, it seems I am getting the expecting
    27   result. So why not setting SET LONG 2000000000 LONGC 2000000000 in your login.sql ?
    28  When I use a LONG setting smaller than the length of the TEXT column, I got it truncated.
    29  When I use a LONG setting smaller than the length of the TEXT column,
    30  I got it truncated. When I use a huge LONG setting but a  setting smallerthe length of the TEXT
    column, I got it wrapped. When both are huge, it seems I am getting ') from dual
    31  /
    TO_CLOB('WHENIUSEALONGSETTINGSMALLERTHANTHELENGTHOFTHETEXTCOLUMN,IGOTITTRUNCATED
    When I use a LONG setting smaller than the length of the TEXT column,
    I got it truncated. When I use a huge LONG setting but a LONGCHUNKSIZE setting s
    maller than the length of the TEXT column, I got it wrapped. When both are huge,
    it seems I am getting the expecting result. So why not setting SET LONG 2000000
    000 LONGC 2000000000 in your login.sql ?
    When I use a LONG setting smaller than the length of the TEXT column, I got it t
    runcated.
    When I use a huge LONG setting but a LONGCHUNKSIZE setting smaller than the leng
    th of the
    TEXT column, I got it wrapped. When both are huge, it seems I am getting the ex
    pecting
    result. So why not setting SET LONG 2000000000 LONGC 2000000000 in your login.s
    ql ?
    When I use a LONG setting smaller than the length of the TEXT column, I got it t
    runcated.
    When I use a LONG setting smaller than the length of the TEXT column,
    I got it truncated. When I use a huge LONG setting but a LONGCHUNKSIZE setting s
    maller than the length of the TEXT column, I got it wrapped. When both are huge,
    it seems I am getting the expecting result. So why not setting SET LONG 2000000
    000 LONGC 2000000000 in your login.sql ?
    When I use a LONG setting smaller than the length of the TEXT column, I got it t
    runcated.
    When I use a huge LONG setting but a LONGCHUNKSIZE setting smaller than the leng
    th of the
    TEXT column, I got it wrapped. When both are huge, it seems I am getting the ex
    pecting
    result. So why not setting SET LONG 2000000000 LONGC 2000000000 in your login.s
    ql ?
    When I use a LONG setting smaller than the length of the TEXT column, I got it t
    runcated.
    When I use a LONG setting smaller than the length of the TEXT column,
    I got it truncated. When I use a huge LONG setting but a LONGCHUNKSIZE setting s
    maller than the length of the TEXT column, I got it wrapped. When both are huge,
    it seems I am getting the expecting result. So why not setting SET LONG 2000000
    000 LONGC 2000000000 in your login.sql ?
    When I use a LONG setting smaller than the length of the TEXT column, I got it t
    runcated.
    When I use a huge LONG setting but a LONGCHUNKSIZE setting smaller than the leng
    th of the
    TEXT column, I got it wrapped. When both are huge, it seems I am getting the ex
    pecting
    result. So why not setting SET LONG 2000000000 LONGC 2000000000 in your login.s
    ql ?
    When I use a LONG setting smaller than the length of the TEXT column, I got it t
    runcated.
    When I use a LONG setting smaller than the length of the TEXT column,
    I got it truncated. When I use a huge LONG setting but a LONGCHUNKSIZE setting s
    maller than the length of the TEXT column, I got it wrapped. When both are huge,
    it seems I am getting the expecting result. So why not setting SET LONG 2000000
    000 LONGC 2000000000 in your login.sql ?
    When I use a LONG setting smaller than the length of the TEXT column, I got it t
    runcated.
    When I use a huge LONG setting but a LONGCHUNKSIZE setting smaller than the leng
    th of the
    TEXT column, I got it wrapped. When both are huge, it seems I am getting the ex
    pecting
    result. So why not setting SET LONG 2000000000 LONGC 2000000000 in your login.s
    ql ?
    When I use a LONG setting smaller than the length of the TEXT column, I got it t
    runcated.
    When I use a LONG setting smaller than the length of the TEXT column,
    I got it truncated. When I use a huge LONG setting but a  setting smallerthe len
    gth of the TEXT column, I got it wrapped. When both are huge, it seems I am gett
    ing
    SQL>

  • Redirecting standart output to a String

    Is there any way to redirecting System.out so that it goes to a string instead of the
    console?

    I am sorry but I am totally unable to understand your question. However if I am anywhere close to what you are asking you just store the value in an instantiated String.
    e.g.
    instead of doing
    System.out.println("hello world");
    String output = "hello world";and then you could append to it
    output.concat("hi there");

  • Strange outputs while parsing String to Double

    Hi All,
    I am writing a simple MIDlet on MIDP 2.0 and CLDC 1.1, where I need to convert two strings into Double calculate their difference and then display the result back on the screen.
    The code I am using is:
        double difference = Double.parseDouble("1235.7") - Double.parseDouble("1234.5");
        String result = (String)Double.toString(difference); The output generated is : 1.2000000000000455 which should be only 1.2
    If I replace the values with "1235" and "1234.1" the output is 0.900000000000091 which should be 0.9
    However, if I change the values to "1235.6" and "1234.1" the output generated is 1.5 which is perfectly fine. Means this happens only for some specific set of values.
    Has anyone ever faced such a situation or if anyone knows a proper workaround to fix this please help me out.
    Thanks.

    Is this normal? does this also happens in case of J2SE I have never tried a similar
    program on j2se.If you are talking about the innaccuracies in the calculations then yes. Look at the url I gave in my previous post, some guy was asking the same thing and it wasn't about J2ME.
    In fact, this happens in every other language as well. It a limitation of the format doubles are stored in.
    shmoove

  • 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

  • XML output as pure string

    Hello,
    I have a requirement to do a MII BLS transaction exposed as Webservice... This WS should return a XML message as a string.
    Problem is that the returned string is xml encoded... But I need it as it!
    So for example, I did a very small transaction with a string output parameter, just containing "<", result is :
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
       <soap:Body>
          <XacuteResponse xmlns="http://www.sap.com/xMII">
             <Rowset>
                <Row>
                   <e>&amp;lt;</e>
                </Row>
             </Rowset>
          </XacuteResponse>
       </soap:Body>
    </soap:Envelope>
    is there a way to avoid this ? And receive <e><</e> ?
    Thanks
    Olivier
    Edited by: Olivier Thiry on May 13, 2011 3:27 PM
    Edited by: Olivier Thiry on May 13, 2011 3:28 PM

    I do it exactly like you say : link xml to string, no encode/decode. In MII Workbench, no problem, it's pure string, but if you consume the WS from any other tool (we tried from SOAP UI, Webdynpro, .Net, or even running the transaction in browser user the SOAPRunner), the result is a XML encoded string.
    If you look at the exemple I provided, you see the response with e = "<" in my MII transaction...
    I think it's more related to SOAP transport, which doesn't allow to have xml inside a xml field...

  • XML output as a string

    Hello
    I am having a XSLT where I am transforming multilevel source XML to a single level target XML. XSLT works fine from XSLTTester utility from SAP.
    The same XSLT I reused in XI and its working fine over there too.But the problem is the output XML what it generates is to be passed as a string to target application class.The target application takes entire XML structure as a string.
    Can anyone knows how this can be done from XI? In ABAP CALL TRANSFORMATION function takes XML string and returns transformed XML string.
    Thanks in advance.
    Regards
    Rajeev

    Hello
    My sender is an XML file which users can upload from a web-page i.e. HTTPSender to XI. This file gets transformed to target XML file using XSLT. My receiver system is SAP R/3 where there is a custom built application which already has got XML interface.This interface is a ABAP-class which has a method to parse the XML.
    This method accepts XML as a string and then creates necessary objects.What I am doing currently is building an RFC in which I am instantiating this class and trying to use the same method to create its object.
    So I want to convert the target XML as one string then my RFC would have only one importing parameter which is string which I could pass to the custom method.
    Do let me know if u have idea about this.
    Thanks in advance.
    Regards
    Rajeev

  • Output from selected string

    i have two table and i am giving the structures bellow
    tWO TABLE
    TBL1
    ID DATA                    COL1 COL2
    1     TESTING 1 DATA      2     DEPTID YEAR
    MESSGAE :TESTING DEPTID DATA 2008 ( 1 REPLACES COL1 VALUE AND 2 REPLACES COL2 VALUE
    TBL2
    ID     DEPTID     NAME
    1     IT     ALEX
    2     AC     GEORGE
    AFTER CALLING OUTPUT SHOULD BE FOR INPUT ID-1
    TESTING IT DATA 2008 . HOW I WILL GET THIS? THROUGH PROCEDURE OR FUNCTION

    (note: UPPERCASE is considered shouting)
    I get the feeling that you have only provided us with half of your actual requirement.
    Based on the little bit you've given us, this will achieve what you want...
    SQL> with tbl1 as (select 1 as id, 'TESTING 1 DATA 2' as data, 'DEPTID' as col1, 'YEAR' as col2 from dual)
      2      ,tbl2 as (select 1 as id, 'IT' as DEPTID, 'ALEX' as name from dual union all
      3                select 2, 'AC', 'GEORGE' from dual)
      4  --
      5  select replace(replace(data, '1', tbl2.deptid), '2', to_char(sysdate, 'YYYY')) as data
      6  from tbl1 join tbl2 on (tbl1.id = tbl2.id)
      7  /
    DATA
    TESTING IT DATA 2008
    SQL>I assume, however, that you are looking for something a little more dynamic in some way, but you need to tell us how.

  • Retrieve multiple row single column output as single string

    hii
    I have query like "select country_name from country_master where <condition>".
    This query results in multiple rows. I want those multiple rows as a string like "country1, country2, contry3".
    I know i can write a function/cursor to achieve that but want to know if we have a way to get that within the query itself.
    Thanks

    In 10g...
    SQL> select dname from dept;
    DNAME
    ACCOUNTING
    RESEARCH
    SALES
    OPERATIONS
    IT SUPPORT
    SQL> ed
    Wrote file afiedt.buf
      1  select ltrim(sys_connect_by_path(dname,','),',') as depts
      2  from (select dname, row_number() over (order by deptno) rn from dept)
      3  where connect_by_isleaf = 1
      4  connect by rn = prior rn + 1
      5* start with rn = 1
    SQL> /
    DEPTS
    ACCOUNTING,RESEARCH,SALES,OPERATIONS,IT SUPPORTIn 11g, you can use the LISTAGG analytical function.

  • Calling Bpel Process From a Jsp(Need a string output instead of XML object)

    Hi
    I am calling a BPEL process(Synchrononus) from a JSP page, Where Bpel process calls a java web service.The output from Bpel process is returned as an XML object. I need the output in a string format.Please let me know the steps to get the string output.
    I also executed invokeCreditRatingService.jsp(from samples shipped with SOA Suite) that calls CreditRatingService bpel, but i was getting the following output where the rating value is printed as an XML object.
    Output:-
    BPELProcess CreditRatingService executed!
    Credit Rating is oracle.xml.parser.v2.XMLElement@9511c8
    Please let me know, what changes i need to make to get the string output.I followed all the steps given in "orabpel-Tutorial7-InvokingBPELProcesses.PDF" to execute credit rating jsp.
    We are using SOA Suite 10.1.3.1.0 version.Do I need to make any changes to the code, to make it work with this version.
    Thanks
    Vandana.

    The call payload.get("payload") returns, as you have observed, an XMLElement. You can simply convert the XMLElement into an XML string by using a DOMSerializer implementation. The following code is very useful for this purpose:
    http://javafaq.nu/java-example-code-432.html
    Best,
    Manfred

  • To store the output of the OutputStream in the String

    I can get the output of the transformer.transform("","") to be printed on the screen, but the aim is to store the output in the String.
    I checked out the API, one way to get the data would be to store the output in the file using.....
    new StreamResult(new File("x.html")) and then get the data. But I am not suppose to use a temporary storage in the form of a file. Is there any other way I can get the data in the form of a String.
    The code is :
    File file = new File("table.xsl");
    StreamSource xslSource = new StreamSource(file);
    File file1 = new File("test.xml");
    StreamSource xmlSource = new StreamSource(file1);
    TransformerFactory tFactory = TransformerFactory.newInstance();
    Transformer transformer = tFactory.newTransformer(xslSource);
    target = new StreamResult(System.out);
    transformer.transform(xmlSource,target);
    Thanks in advance.
    manibhat

    Hi ecbouma,
    Thanks for the solution.
    I came across another approach..
    StringWriter sw = new StringWriter();
    PrintStream ps = new PrintStream(sw);
    sw.toString();
    It works fine...
    I have a question over here...
    PrintStream takes an argument that extends OutputStream, but looks like StringWriter does not extend OutputStream...
    I am not sure why does the above code works.
    manibhat

  • How to output strings to a file faster.

    Hi,
    I need to output large among strings to a file. The requirement is that the time of file processing shall be as short as possible. So I implemented as following:
    Define a StringBuffer and append all the strings first. Open file. Using BufferedWrite to write into it. Close file.
    It works. But sometimes I got OutOfMemoryException if there are to many strings. To avoid this I increased memory.
    I wonder if there is any other solution to do it without increasing memory?
    Saga

    Hi!
    As I understand your problem, you have two possible solutions.
    1. change your approach to somthing like appanding only a fixed number of strings to a stringbuffer and write it to the file (appending each time your write the buffer), clear the stringbuffer. This will prevent from OutOfMenory exceptions but increase file activity.
    2. append the strings directly to the file to prevent OutOfMenory exceptions.This way you have short but frequent file activity.
    Hope this helps
    Timo

  • Output strings from loop into one string

    im trying my best to explain my problem so ber in mind:)
    hey having a bit of trouble with outputing strings from loop
    example
    i typed ab into the textbox
    the output should be 12
    but since it is in a loop it would only output the last string and in this case is 2
    im trying to get both strings from the loop and output strings from loop into one string.
    here is some of my code to understand my problem
    // characters a to f
         char[] charword = {'a','b','c','d','e','f'};
         String charchange ;
      // get text from password textbox
                          stringpassword = passwordTextbox.getText();
                          try {
                          // loop to show password length
                          for ( int i = 0; i < stringpassword.length(); i++ ){
                          // loop to go through alfabet     
                          for (int it = 0; it < charword.length; it++){
                             // if char equals stringwords
                               if (stringpassword.charAt(i) == charword[it]){
                                    System.out.print("it worked");
                                    // change characters start with a
                                    if (charword[it] == 'a'){
                                         charchange = "1";
                                    // change to 2
                                    if (charword[it] == 'b'){
                                         charchange = "2";
                                        }

    Not sure how you are displaying the result but you could display each value as soon as you find it.
    if (charword[it] == 'a'){
        System.out.print("1");
    }If it is in a text field then use append. Or if you really need a String with the entire result then use concatenation.
    if (charword[it] == 'a'){
        charchange += "1";
    }

  • Variable string output

    I have searched tons of forums and cant seem to find code that will allow me to output the users string inputs to the dos screen.
    An example of this would be.
    Enter shopping items: Ham
    another?: yes
    Enter shopping items: Eggs
    another?: no
    Your list contains:
    Ham
    Eggs
    here is my code:
    System.out.println("This program will create a shopping list:");
    String keepGoing = "yes";
    String item = null;
    Scanner keyboard = new Scanner(System.in);
    for (int count = 1; count < 999 && keepGoing.equalsIgnoreCase("yes");count++){//ask for input, write it to a file
    System.out.println("Please enter item #" + count + ":");
    item = keyboard.nextLine();
    inputItems.println(count + " " + item);//ask if you want to keep going
    System.out.println("Do you wish to enter more items (yes/no)");
    keepGoing = keyboard.nextLine();
    System.out.println("Your shopping list contains: " + ); ***** Not sure what to put in the above ("Your shopping list contains: " + ) "******
    Any help?

    check the comments...
           // ...... (your other bits of code)
            // Use a boolean variable instead of a Stirng
            boolean keepGoing = true;
            // keep looping until user says 'no'
            while(keepGoing)
                // ...... (your other bits of code)
                System.out.println("Do you wish to enter more items (yes/no)");
                String temp = keyboard.nextLine();
                // anything other than yes is a no!
                keepGoing = temp.equalsIgnoreCase("yes");
             // ...... (your other bits of code)
            }hope this helps...
    [email protected]

  • Multiple strings input to single string output

    Dear all,
    this program is needed for my demo simulation purposes, I'm creating several string inputs to show into a single string output updating (input strings are shown in each line). i attached the picture below, put 2 output strings w/c both doesn't meet my desired result:
    1.) 1st string output - replace the old string w/ new string. what i need is to maintain also the previous strings. the new string will go to the next line.
    2.) 2nd string output - although i got all the strings i needed, it only appears right after the while loop terminates, so i did not see the string inputs updating.
    i'm using LV 8.5.1., any help is appreciated... posting your correct code will be more appreciated.
    thanks in advance...
    Ivel R. | CLAD
    Solved!
    Go to Solution.

    here's my code for anyone to see the actual difference.
    thanks,
    Ivel R. | CLAD
    Attachments:
    update strings.vi ‏14 KB

Maybe you are looking for

  • Auto indent is not working in Dreamweaver

    Hi, I'm using Dreamweaver CS5 on Windows 7 and the auto indent in the Code pane is not working. All settings are at default after installation. The Indent option in Code Format in the Preferences is checked and set to 2 Spaces. Auto Indent is also ch

  • ICloud back up insists on backing up camera reel

    Hi Back up is too big so I keep turning the icloud setting to back up camera reel OFF in settings. It appears ok then when it goes to back up itself when put on charge, off it goes again saying back up too large and lo and behold, the back up camera

  • Powerbook display went out, Help!

    I was just using Safari, and seemingly out of nowhere, I heard a loud whirring (I think from the optical drive) and then the display went black--mostly, I can still sort of make out the menu bar and dock. I've had this happen once before, but that ti

  • 5530 XM Firmware v30 not for everyone

    What's the difference between these two versions of the phone?? Product code 0581328: RM-504 North America BLACK-RED (for this one the firmware is available) Product code 0590825: 5530 XM RM-504 North America US Black/Red (for this one not) I have th

  • Receive error when downloading adobe air on iPad

    I receive an error every time I click on the link to download adobe air? Can anyone help? Thanks, Jim