New to Graphics, trying to display array output in a single window

I am trying to figure out how to use the GUI components of JAVA.
What I am trying to do is take my packaged array output and list it in a single window. All that ever prints is last array data set. The last keeps overwritting the previous. How do I keep the previous data shown while listing the next in the array?
Below are my three classes. The Frame Class is the class containing the display method. It is called near the bottom of the Product Class.
Product.java
// Inventory Program Part 4
/* This program will store multiple entries
for office supplies, give the inventory value,
sort the data by Product Name,
and output the results using a GUI */
import javax.swing.text.JTextComponent;
import javax.swing.JLabel;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JOptionPane; //Uses class JOptionPane
import java.util.Scanner; //Uses class Scanner
import java.util.Arrays; //Uses class Arrays
public class Product
     private String productBrand[]; // Declares the array
     public void setProductBrand( String brand[] ) // Declare setProductBrand method
          productBrand = brand; // stores the productbrand
     } // End setProductBrand method
     public String getProductBrand( int counter )  // Declares getProductBrand method
          return productBrand[ counter ]; // Returns data using counter to define the element
     } // End method getProductBrand
     public double restockingFee( double value ) // Declares restocking Fee method
          double fee = 0; // Declares variable fee
          fee = value * 0.05; // Calculates the sum of values
          return fee;  // Returns the restocking fee
     } // End method restockingFee     
     public String inventoryValue( double value[] , int number, String name[] ) // Declares inventoryValue method
          OfficeSupplies myOfficeSupplies = new OfficeSupplies();  //Creates OfficeSupplies Object
          Product myProduct = new Product();
          double total = 0; // Declares variable total
          for ( int counter = 0; counter < number ; counter++ )
               total += ( value[ counter ] + myProduct.restockingFee( value[ counter ] ) ); // Calculates the sum of values
                    return String.format( "%s$%.2f", "Total Inventory Value: " , total );  // Returns the total value
     } // End method inventoryValue
     // main method begins execution
     public static void main( String args[] )
          Scanner input = new Scanner( System.in ); //Creates Scanner object to input from command window
          Product myProduct = new Product(); //Creates Product object
          OfficeSupplies myOfficeSupplies = new OfficeSupplies();  //Creates OfficeSupplies Object          
          //Prompt for maxNumber using JOptionPane
          String stringMaxNumber =
               JOptionPane.showInputDialog( "Enter the number of products you wish to enter" );
          int maxNumber = Integer.parseInt( stringMaxNumber );     
          String prodName[] = new String[ maxNumber ]; // Declares prodName array
          int numberUnits[] = new int[ maxNumber ]; // Declares maxNumber array          
          float unitPrice[] = new float[ maxNumber ]; // Declares unitPrice array
          double value[] = new double[ maxNumber ]; // Declares value array
          String brand[] = new String [ maxNumber ]; // Declares brand array
          String stringNumberUnits[] = new String [ maxNumber]; // Declares array
          String stringUnitPrice[] = new String [ maxNumber ]; // Declares array
          int productNumber[] = new int[ maxNumber ]; // Declares array
          for ( int counter = 0; counter < maxNumber; counter++ ) // For loop for the number of products to enter
               productNumber[ counter ] = counter;
               myOfficeSupplies.setProductNumber( productNumber ); // Sends the Product name to method setProductNumber                         
               //Prompt for product name using JOptionPane
               prodName[ counter ] =
                    JOptionPane.showInputDialog( "Enter the Product Name" );
               myOfficeSupplies.setProductName( prodName ); // Sends the Product name to method setProductName
               //Prompt for brand name using JOptionPane
               brand[ counter ] =
                    JOptionPane.showInputDialog( "Enter the Brand name of the Product" );
               myProduct.setProductBrand( brand ); // Sends the Brand name to method setProductBrand
               //Prompt for number of units using JOptionPane
               stringNumberUnits[ counter ] =
                    JOptionPane.showInputDialog( "Enter the Number of Units" );
               numberUnits[ counter ] = Integer.parseInt( stringNumberUnits[ counter ] );
               myOfficeSupplies.setNumberUnits( numberUnits ); // Sends the Number Units to the method setNumberUnits
               //Prompt for unit price using JOptionPane
               stringUnitPrice[ counter ] =
                    JOptionPane.showInputDialog( "Enter the Unit Price" );
               unitPrice[ counter ] = Float.parseFloat( stringUnitPrice[ counter ]);
               myOfficeSupplies.setUnitPrice( unitPrice ); // Sends the Unit Price to the method setUnitPrice
               value[ counter ] = numberUnits[ counter ] * unitPrice[ counter ]; // Calculates value for each item
               myOfficeSupplies.setProductValue( value ); // Sends the product value to the method setProductValue
          Arrays.sort( prodName, String.CASE_INSENSITIVE_ORDER ); // Calls method sort from Class Arrays
               Frame myFrame = new Frame();
               myFrame.displayData( myProduct, myOfficeSupplies, maxNumber );
          // Outputs Total Inventory Value using a message dialog box
          JOptionPane.showMessageDialog( null, myProduct.inventoryValue( value, maxNumber, prodName ),
               "Total Inventory Value", JOptionPane.PLAIN_MESSAGE );
     } // End method main
} // end class ProductOfficeSupplies.java ----> This is the data container
// Inventory Program Part 4
/* Stores the array values */
public class OfficeSupplies // Declaration for class Payroll
     private int productNumber[];
     public void setProductNumber( int number[] ) // Declare setProductNumber method
          productNumber = number; // stores the product number
     } // End setProductNumber method
     public int getProductNumber( int counter )  // Declares getProductNumber method
          return productNumber[ counter ];
     } // End method getProductNumber
     private String productName[];
     public void setProductName( String name[] ) // Declare setProductName method
          productName = name; // stores the Product name
     } // End setProductName method
     public String getProductName( int counter )  // Declares getProductName method
          return productName[ counter ];
     } // End method getProductName
     private int numberUnits[];
     public void setNumberUnits( int units[] ) // Declare setNumberUnits method
          numberUnits = units; // stores the number of units
     } // End setNumberUnits method
     public int getNumberUnits( int counter )  // Declares getNumberUnits method
          return numberUnits[ counter ];
     } // End method getNumberUnits
     private float unitPrice[];
     public void setUnitPrice( float price[] ) // Declare setUnitPrice method
          unitPrice = price; // stores the unit price
     } // End setUnitPrice method
     public float getUnitPrice( int counter )  // Declares getUnitPrice method
          return unitPrice [ counter ];
     } // End method getUnitPrice
     private double productValue[];
     public void setProductValue( double value[] ) // Declare setProductValue method
          productValue = value; // stores the product value
     } // End setProductValue method
     public double getProductValue( int counter )  // Declares getProductValue method
          return productValue[ counter ];
     } // End method getProductValue
} // end class OfficeSuppliesFrame.java ------> Contains the display method
import java.awt.Color;
import javax.swing.text.JTextComponent;
import javax.swing.JLabel;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JOptionPane; //Uses class JOptionPane
public class Frame extends JFrame
     public Frame() //Method declaration
          super( "Products" );
     } // end frame constructor
     public void displayData( Product myProduct, OfficeSupplies myOfficeSupplies, int maxNumber )
          //Here I attempted to use an array to output all of the array data in a single window
//          JTextArea myTextArea[] = new JTextArea[ maxNumber ]; // Declares myTextArea array to display output
          JTextArea myTextArea = new JTextArea(); // textarea to display output
          // For loop to display data array in a single Window
          for ( int counter = 0; counter < maxNumber; counter++ )  // Loop for displaying each product
//               myTextArea[ counter ].setText( packageData( myProduct, myOfficeSupplies, counter ) + "\n" );
//                add( myTextArea[ counter ] ); // add textarea to JFrame
               myTextArea.setText( packageData( myProduct, myOfficeSupplies, counter ) + "\n" );
               add( myTextArea ); // add textarea to JFrame
          } // End For Loop
          setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
          setSize( 450, maxNumber*400 ); // set frame size
          setVisible( true ); // display frame
     public String packageData( Product myProduct, OfficeSupplies myOfficeSupplies, int counter ) // Method for formatting output
          return String.format( "%s: %d\n%s: %s\n%s: %s\n%s: %s\n%s: $%.2f\n%s: $%.2f\n%s: $%.2f\n%s: $%.2f",
          "Product Number", myOfficeSupplies.getProductNumber( counter ),
          "Product Name", myOfficeSupplies.getProductName( counter ),
          "Product Brand",myProduct.getProductBrand( counter ),
          "Number of Units in stock", myOfficeSupplies.getNumberUnits( counter ),
          "Price per Unit", myOfficeSupplies.getUnitPrice( counter ),
          "Total Value of Item in Stock is", myOfficeSupplies.getProductValue( counter ),
          "Restock charge this product is", myProduct.restockingFee( myOfficeSupplies.getProductValue( counter ) ),
          "Total Value of Inventory plus restocking fee", myOfficeSupplies.getProductValue( counter )+
               myProduct.restockingFee( myOfficeSupplies.getProductValue( counter ) ) );
     } // end method packageData
}

Lets pretend that your assignment was to manage a list of employees of a store, and that each employee is identified by their name, position, and hourly wage. If you created a program along the lines of your current product program, I picture you creating three separate ArrayLists (or arrays), one for each variable, something like this:
import java.util.ArrayList;
public class MyEmployees1
    private ArrayList<String> names = new ArrayList<String>();
    private ArrayList<String> positions = new ArrayList<String>();
    private ArrayList<Double> hourlyWages = new ArrayList<Double>();
    public void add(String name, String position, double wage)
        names.add(name);
        positions.add( position);
        hourlyWages.add(wage);
    public void removed()
        // TODO: I am nervous about trying to manage this!
    //.......... more
}This program tries to manage three separate parallel arrays (arraylists actually). They are parallel because the 3rd item in the names list corresponds to the 3rd item in the positions list and also the hourlywages list. If I wanted to delete data, I'd have to be very careful to delete the correct item in all three lists. If I tried to sort one list, I'd have to sort the other two in exactly the same way. It is extremely easy to mess this sort of program up.
Now lets look at a different approach. Say we created a MyEmployee class that contains the employee's name, position, and wage, along with the appropriate constructors, getters, setters, toString method, etc... something like so:
import java.text.NumberFormat;
public class MyEmployee
    private String name;
    private String position;
    private double hourlyWage;
    public MyEmployee(String name, String position, double hourlyWage)
        this.name = name;
        this.position = position;
        this.hourlyWage = hourlyWage;
    public String getName()
        return name;
    public String getPosition()
        return position;
    public double getHourlyWage()
        return hourlyWage;
    public String toString()
        // don't worry about these methods here.  They're just to make the output look nice
        NumberFormat currency = NumberFormat.getCurrencyInstance();
        return String.format("Name: %-15s    Position: %-15s    Wage: %s",
                name, position, currency.format(hourlyWage));
}Now I can create a MyEmployees2 class that holds a single list of MyEmployee objects, like so:
import java.util.ArrayList;
public class MyEmployees2
    private ArrayList<MyEmployee> employeeList = new ArrayList<MyEmployee>();
    public boolean add(MyEmployee employee)
        return employeeList.add(employee);
    public boolean remove(MyEmployee employee)
        return employeeList.remove(employee);
    public void display()
        for (MyEmployee employee : employeeList)
            System.out.println(employee);
    public static void main(String[] args)
        MyEmployees2 empl2 = new MyEmployees2();
        empl2.add(new MyEmployee("John Smith", "Salesman", 20));
        empl2.add(new MyEmployee("Jane Smyth", "Salesman", 25));
        empl2.add(new MyEmployee("Fred Flinstone", "Janitor", 15));
        empl2.add(new MyEmployee("Barney Rubble", "Supervisor", 35));
        empl2.add(new MyEmployee("Mr. Spacely", "The Big Boss", 45));
        empl2.display();
}Now if I want to add an Employee, I only add to one list. Same if I want to remove, only one list, and of course, the same for sorting. It is much safer and easier to do things this way. Make sense?

Similar Messages

  • I am trying to display the output from my ipod touch on apple tv. i can get the audio but no video. please help

    i am trying to display the output from my ipod touch on apple tv. i can get the audio but no video. Thank you for any advice.

    What output are you trying to get to your tv?

  • Display XML forms in a single window-URGENT!!!!!!!

    Hi,
    I created a project with XML forms Builder. It is working but the thing is that now i just want to display all the forms in the same window. Means that when i want to edit a new item instead of a new window i want to work in the same browser.
    Is that possible by configuring a resource renderer(NewsRenderer for example)?
    Otherwise do u know another solution?
    Please i need help.
    I found a topic in the forum (thread below) https://forums.sdn.sap.com/thread.jspa?threadID=46122&messageID=466382
    But i didn't understand all the points.
    So if someone know something please answer.
    Thx in advance.
    MJ

    Hi Robert,
    I did as u said: I downloaded the file <u>YOUR_PROJECT_NewsRenderListItem.xsl</u> but i didn't find any <b>_blank</b> in the text. Let's say i have exactly the same problem than in the previous thread, i don't know where to add the URL and where to replace _blank.
    I don't know where to find the method <u>CreateXSLDocument</u>(Detlev thread) and what is its interest?
    Can u please explain where i can find "xinfo=window.open(url,'_blank',params)"? It should be (according to Detlev) in <u>com.sapportals.wcm.app.xfbuilder.server.generator.xsldocs.CreateXSLDocument</u> but i really don't know how to reach this address.
    Thx a lot!!!
    best regards
    MJ

  • Displaying multiple messages in a single window

    Hi,
    i have several messages in an internal table and i need to display all those with in the same dialog box/window. is there any function module to do that.
    Regards,
    ravi.

    Hi,
    You can use FM 'SLS_MISC_SHOW_MESSAGE_TAB'.
    DATA: it_messages LIKE sls_msgs OCCURS 0 WITH HEADER LINE.
    START-OF-SELECTION.
      CLEAR it_messages.
      MOVE '001' TO it_messages-num.
      MOVE 'message001' TO it_messages-msg.
      APPEND it_messages.
      CLEAR it_messages.
      MOVE '002' TO it_messages-num.
      MOVE 'message002' TO it_messages-msg.
      APPEND it_messages.
      CLEAR it_messages.
      MOVE '003' TO it_messages-num.
      MOVE 'message003' TO it_messages-msg.
      APPEND it_messages.
      CALL FUNCTION 'SLS_MISC_SHOW_MESSAGE_TAB'
        TABLES
          p_messages                 = it_messages
      EXCEPTIONS
        NO_MESSAGES_PROVIDED       = 1
        OTHERS                     = 2

  • Display counter output on graph

    I have two counters generating continuous digial pulse trains from my PCI 6010, and I'm trying to display the output on a graph.  I've got the output of one counter connected to an AI line that leads to a waveform graph, but I can't get anything on the graph.  I've measured the output via external means, so I know the counters are generating the appropriate pulses.
    Eventually I'd like to have some sort of indicator for each counter that indicates whether the counter is in the 'on' or 'off' state, but I figured getting the counter outputs to diplay on a graph would be a good first step.
    My VI is below; the display part that isn't working is at the bottom of the case structure.
    Thanks.

    Once your code goes into the inner while loop your graph will never be updated since it will only execute one time. In order to update the graph continually you will need a parallel which handles the graph updates. A good way to pass data between the parallel tasks is a queue.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • "Output could not be issued" when trying to display the layout of the order

    "Output could not be issued" error comes when trying the display layout of the order confirmation.
    Thanks

    Hi,
    This error is faced generlly when output type has not been assigned to the document type.In sales order Follow the path
    Goto-Extras-Output-Header-Edit.
    Here mention the output type and communication medium and save the document.
    Now try to issue the output.
    I assume that you have maintain the output determination procedure in SPRO.
    For automatic determination of output maintain the output condition record
    Reward points if useful
    Regards,
    Amrish Purohit

  • HT1338 When trying to update getting (error surle error domain error-1100). It started yesterday, any help would be great. I have Mountain Lion 10.8.1 on a new macbook pro with retina display.

    When trying to update getting (error surle error domain error-1100). It started yesterday, any help would be great. I have Mountain Lion 10.8.1 on a new macbook pro with retina display.

    There are many people suffering from this problem right now (including me). It appears to be a server issue. Just wait and try checking for updates again tomorrow.
    Some things I have heard indicate that this may be a regional problem, though what parts of the world are affected I don't know yet. A few people have been helped by deleting the following preference file (paste the path into the Go -> Go to Folder window in the Finder to locate it), though most have not:
    ~/Library/Preferences/com.apple.SoftwareUpdate.plist
    Note that if you are trying to download iTunes 10.7, that can be found here:
    http://support.apple.com/kb/DL1576
    Also, note that there is no reason to be anxious to get it, as the only thing added in iTunes 10.7 is compatibility with iOS 6, which will not be available until the 19th, and the new iPhone, which will not be available until later as well. The new iTunes that was announced is iTunes 11, which is also not yet available.

  • Placed an image in a new Illustrator document.  Tried to change the Output Mode in the Output Dialog but could not select "Separations Mode".

    Placed a DCS2 document image in a new Illustrator document. 
    Tried to change the Output Mode in the Output Dialog but could not select "Separations Mode".

    I would check with the makers of ULTRASEPS.
    I never heard of it, just checked their website, I don't think they support Illustrator:
    What do I need to use UltraSeps?
    UltraSeps requires Adobe Photoshop version CS2 or higher on Windows and Macintosh.
    Its also 100% compatible with Photoshop Creative Cloud and Creative Cloud 2014.

  • Moved Graphics Don't Display In Flash Output

    Following on from my previous post (re the problems I have
    had following an upgrade from v4 to v6) in which I mentioned that
    many of my graphics do not display in preview mode, even having
    moved the project to my C drive and even though the images do
    display in compiled .chm output, they still will not display in
    preview mode or in compiled Flash output (have not yet tested
    WebHelp).
    However, this does not apply to all of the graphics in my
    project - It would appear that the problem images are only those
    which having opened the project in v6, I moved into a central
    graphics folder (using the Project view).
    Beforehand, all my images were scattered throughout the
    project folders which made it a nightmare to manage so I decided to
    move those which were not already located in my 'Images' folder,
    into it!
    Although the file moves seemed to work without any problems
    and the code in the 'True Code' view points to the correct location
    (and does not show any obvious differences between graphics which
    do display in preview mode and those which don't) - all I get is a
    box the size and shape of the graphic containing a small red cross!
    Any suggstions gratefully received as always.
    Ta much

    In dealing with the various problems, did you take a copy of
    the project and then open that using the HHP file after deleting
    the CPD and XPJ files? Try that on a copy to see if it fixes the
    problem. If it does, read my topic on Opening a Project to see if
    any of the issues concern your project.
    If that doesn't fix it, post back.

  • Trying to display a pdf inline, in a new window.

    Hello
    I have a servlet with the following html button.
    <FORM NAME=download ACTION=/servlet.ShowReportServlet METHOD=get>
    <INPUT TYPE='submit' VALUE='Display Report A' NAME='Report'>
    When this button is pressed, a pdf file is displayed via the following code
    // Store the uploaded file size
         int filesize = bis.available();
         // Set content type to application/pdf for Adobe Acrobat Reader
         response.setContentType("application/pdf");
         // Content-Disposition is a field to specify presentation of
         // entity or file name (incase Acrobat Reader plug-in not installed)
         response.setHeader(
              "Content-Disposition",
              "inline; filename=\"" + fileToUpload + "\"");
         // Do not cache the pdf file
         response.setHeader("Cache-Control", "no-cache");
         // Set the content length
         response.setContentLength(filesize);
         // Upload the file to the client
         ServletOutputStream sos = response.getOutputStream();
         int data;
         while ((data = bis.read()) != -1) {
              sos.write(data);
    My problem is that I can't work out how to display the pdf in a new browser window.
    Any help would be greatly appreciated.
    Thankyou.

    Thanks for pointing me in the right direction DrClap.
    We ended up with the following html (in an HttpServletResponse):
    <FORM NAME=download ACTION=/servlet.ShowReportServlet METHOD=get TARGET="ReportWindow">
    <INPUT TYPE='submit' VALUE='Display Report A' NAME='Report' OnClick="window.open('','ReportWindow','height=530,width=550,menubar=0,resizable=1,scrollbars=1, status=0,titlebar=0,toolbar=0,left=300,top=100')">

  • XSLT - New Line/Carriage Return not displaying when deployed

    Hello everyone,
    I have an XSL Style Sheet that is supposed to transform an XML into plain text using Oracle SOA 11g BPEL transformation. The plain text transformation is working fine, but whenever I try to add a new line or carriage return, the text output doesn't reflect that. I've tried several ways of adding the line break but none of them have worked. This is the XSLT I'm using for testing purposes:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="urn:oracle:b2b:X12/V4010/850" version="1.0">
    <xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
    <xsl:template match="/a:Transaction-850">
    <!-- New line -->
    <xsl:variable name='newline'><xsl:text>
    </xsl:text></xsl:variable>
    <xsl:value-of select="a:Internal-Properties/a:Data-Structure/a:Property[@Name='InterchangeUsageIndicator']" />
    <xsl:text>&#xd;</xsl:text>
    <xsl:value-of select="$newline" />
    <xsl:text>&#xA;</xsl:text>
    <xsl:text>&#13;</xsl:text>
    <xsl:text>&#10;</xsl:text>
    <xsl:text>2000ITITM</xsl:text>
    </xsl:template>
    </xsl:stylesheet>
    When I try it out in an online XSLT test tool, it gives the output as expected:
    P
    2000ITITM
    When I deploy the composite, I noticed that the XSLT in the MDS repository ignores the line breaks, *#xAs, etc. and just closes the <xsl:text/> tags:
    <?xml version='1.0' encoding='UTF-8'?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:a="urn:oracle:b2b:X12/V4010/850" version="1.0">
    <xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
    <xsl:template match="/a:Transaction-850">
    <xsl:variable name="newline">
    <xsl:text/>
    </xsl:variable>
    <xsl:value-of select="a:Internal-Properties/a:Data-Structure/a:Property[@Name='InterchangeUsageIndicator']"/>
    <xsl:text/>
    <xsl:value-of select="$newline"/>
    <xsl:text/>
    <xsl:text/>
    <xsl:text>2000ITITM</xsl:text>
    </xsl:template>
    </xsl:stylesheet>
    And so, because of that, it just gives me the following output:
    P2000ITITM
    I have no idea why it's ignoring the new line characters, so any guidance would be appreciated.
    Thank you all for your help and time!
    Edit: I tried concatenating as follows:
    <xsl:value-of select="concat('36','&#xA;')"/>
    <xsl:value-of select="concat('24','&#xD;')"/>
    ...which shows up as is when I look at it in the MDS repository, however the text output still shows no line breaks...
    Message was edited by: dany36

    Ah I'm such a newbie. I was able to get it displayed by doing the following:
    <xsl:variable name="newline" select="'&#xD;&#xA;'" />
    This would show up correctly in the MDS repository, too.

  • // Code Help need .. in Reading CSV file and display the Output.

    Hi All,
    I am a new Bee in code and started learning code, I have stared with Console application and need your advice and suggestion.
    I want to write a code which read the input from the CSV file and display the output in console application combination of first name and lastname append with the name of the collage in village
    The example of CSV file is 
    Firstname,LastName
    Happy,Coding
    Learn,C#
    I want to display the output as
    HappyCodingXYZCollage
    LearnC#XYXCollage
    The below is the code I have tried so far.
     // .Reading a CSV
                var reader = new StreamReader(File.OpenRead(@"D:\Users\RajaVill\Desktop\C#\input.csv"));
                List<string> listA = new List<string>();
                            while (!reader.EndOfStream)
                    var line = reader.ReadLine();
                    string[] values = line.Split(',');
                    listA.Add(values[0]);
                    listA.Add(values[1]);
                    listA.Add(values[2]);          
                    // listB.Add(values[1]);
                foreach (string str in listA)
                    //StreamWriter writer = new StreamWriter(File.OpenWrite(@"D:\\suman.txt"));
                    Console.WriteLine("the value is {0}", str);
                    Console.ReadLine();
    Kindly advice and let me know, How to read the column header of the CSV file. so I can apply my logic the display combination of firstname,lastname and name of the collage
    Best Regards,
    Raja Village Sync
    Beginer Coder

    Very simple example:
    var column1 = new List<string>();
    var column2 = new List<string>();
    using (var rd = new StreamReader("filename.csv"))
    while (!rd.EndOfStream)
    var splits = rd.ReadLine().Split(';');
    column1.Add(splits[0]);
    column2.Add(splits[1]);
    // print column1
    Console.WriteLine("Column 1:");
    foreach (var element in column1)
    Console.WriteLine(element);
    // print column2
    Console.WriteLine("Column 2:");
    foreach (var element in column2)
    Console.WriteLine(element);
    Mark as answer or vote as helpful if you find it useful | Ammar Zaied [MCP]

  • Display Report Output in Email Body (EBS).

    Hi,
    I was wondering if it is possible to display the output of a BIP report within the body of an email using bursting instead of having the report in an attachment.
    Thanks in advance
    Carl

    Hi Carl,
    I use the API directly:
         // Parse RTF og lav XSL
                   ByteArrayOutputStream xsl;
                   xsl = new ByteArrayOutputStream(1024);
                   RTFProcessor rtfProc = new RTFProcessor(rtfPath);
                   rtfProc.setOutput(xsl);
                   rtfProc.process();
                   xsl.flush();
                   xsl.close();
                   // Lave rtf udfra xml og det nye xsl
                   BufferedOutputStream bout = new BufferedOutputStream(new FileOutputStream(output));
                   ByteArrayInputStream xmlStream = new ByteArrayInputStream(xml);
                   FOProcessor foProc = new FOProcessor();
                   foProc.setTemplate(new ByteArrayInputStream(xsl.toByteArray()));
                   foProc.setData(xmlStream);
                   foProc.setOutput(bout);
                   foProc.setOutputFormat(FOProcessor.FORMAT_RTF);
                   foProc.generate();
                   bout.flush();
                   bout.close();
    I can change the output format to HTML (haven't tried) -> and then send the email with contenttype html. Can I email directly via the api ?

  • How to display array

    Hi, I have a problem to display array from my database. The following are the two files that I tried to input multiple values in mailaddress database in the second file and I tried to display the values from the database when the user login the first file. The values are recorded in the database well but I always got java.lang.NullPointerException error in my first file. I checked the code, it shows that array display wrong. Would you please help me? Thanks a lot in advance.
    <zhangmailinputtest.jsp>
    <%@ page language="java" contentType="text/html; charset=Shift_JIS" %>
    <%@ page import="beanYama.*,java.sql.*,java.util.*,java.text.*" %>
    <%@ include file="inc_conv_char.jsp" %>
    <%
    String uid =(String)session.getAttribute("uid");
    String unam =(String)session.getAttribute("unam");
    String depart =(String)session.getAttribute("depart");
    String perms =(String)session.getAttribute("perms");
    String flag =(String)session.getAttribute("flag");
    if(flag==null){
         response.sendRedirect("index.jsp");
    }else{
    %>
    <html>
    <body>
    <%!      String[] name;
         String[] departa;
         String[] email;
    %>
    <%
              Connection con = null;
              Statement stmt1 = null;
              ResultSet rsq = null;
              Class.forName("org.gjt.mm.mysql.Driver");
              con=DriverManager.getConnection("jdbc:mysql://localhost/progress?user=ntjs&password=ntjs&useUnicode=true&characterEncoding=Shift_JIS");
              stmt1=con.createStatement();
         rsq=stmt1.executeQuery("SELECT name AS name1 from mailaddress;");
              if(rsq.next()){
                   for (int i=0;i<name.length;i++) {
                   name[i] = rsq.getString("name1");
                   rsq.next();
              stmt1.close();
              con.close();     
    %>
    <form action="zhangmailtestfinal.jsp" method="post">
    <table width="60%" border="1" cellpadding="1" cellspacing="1" bordercolor="#000099">
    <tr>
    <td width="20%"><div align="center">Name</div></td>
    <td width="20%"><div align="center">Department</div></td>
    <td width="50%"><div align="center">Address</div></td>
    </tr>
    <tr>
    <td><input type="text" name="name" size="25" value="<%=name[0]%>" align="middle"></td>
    <td><input type="text" name="departa" size="25" align="middle"></td>
    <td><input type="text" name="email" size="53"align="middle"></td>
    </tr>
    <tr>
    <td><input type="text" name="name" size="25" align="middle"></td>
    <td><input type="text" name="departa" size="25" align="middle"></td>
    <td><input type="text" name="email" size="53"align="middle"></td>
    </tr>
    <td><input type="text" name="name" size="25" align="middle"></td>
    <td><input type="text" name="departa" size="25" align="middle"></td>
    <td><input type="text" name="email" size="53"align="middle"></td>
    </tr>
    <tr>
    <td><input type="text" name="name" size="25" align="middle"></td>
    <td><input type="text" name="departa" size="25" align="middle"></td>
    <td><input type="text" name="email" size="53"align="middle"></td>
    </tr>
    <td><input type="text" name="name" size="25" align="middle"></td>
    <td><input type="text" name="departa" size="25" align="middle"></td>
    <td><input type="text" name="email" size="53"align="middle"></td>
    </tr>
    <tr>
    <td><input type="text" name="name" size="25" align="middle"></td>
    <td><input type="text" name="departa" size="25" align="middle"></td>
    <td><input type="text" name="email" size="53"align="middle"></td>
    </tr>
    <td><input type="text" name="name" size="25" align="middle"></td>
    <td><input type="text" name="departa" size="25" align="middle"></td>
    <td><input type="text" name="email" size="53"align="middle"></td>
    </tr>
    <tr>
    <td><input type="text" name="name" size="25" align="middle"></td>
    <td><input type="text" name="departa" size="25" align="middle"></td>
    <td><input type="text" name="email" size="53"align="middle"></td>
    </tr>
    <td><input type="text" name="name" size="25" align="middle"></td>
    <td><input type="text" name="departa" size="25" align="middle"></td>
    <td><input type="text" name="email" size="53"align="middle"></td>
    </tr>
    <tr>
    <td><input type="text" name="name" size="25" align="middle"></td>
    <td><input type="text" name="departa" size="25" align="middle"></td>
    <td><input type="text" name="email" size="53"align="middle"></td>
    </tr>
    </table>
    <input type="submit" name="save_button" value="Save">
    </body>
    </CENTER>
    </html>
    <%
    %>
    <zhangmailtestfinal.jsp>
    <%@ page language="java" contentType="text/html; charset=Shift_JIS" %>
    <%@ page import="beanYama.*,java.sql.*,java.util.*,java.text.*" %>
    <%@ include file="inc_conv_char.jsp" %>
    <%
    String uid =(String)session.getAttribute("uid");
    String unam =(String)session.getAttribute("unam");
    String depart =(String)session.getAttribute("depart");
    String perms =(String)session.getAttribute("perms");
    String flag =(String)session.getAttribute("flag");
    if(flag==null){
         response.sendRedirect("index.jsp");
    }else{
    %>
    <html>
    <body>
    <%!
         Connection con = null;
         PreparedStatement ps = null;
         ResultSet rs = null;
    %>
    <%
         String[] name = request.getParameterValues("name");
         String[] departa = request.getParameterValues("departa");
         String[] email = request.getParameterValues("email");
    try{          
              Class.forName("org.gjt.mm.mysql.Driver");
              con=DriverManager.getConnection("jdbc:mysql://localhost/progress?user=ntjs&password=ntjs&useUnicode=true&characterEncoding=Shift_JIS");
              Statement stmt0=con.createStatement();
              stmt0.executeUpdate("delete from mailaddress");
              String query ="INSERT INTO mailaddress (mail_userid,name,departa,email) VALUES (?,?,?,?)";
              ps = con.prepareStatement(query);
                   for (int i=0;i<name.length;i++){
                   ps.setString(1,uid);
                   ps.setString(2, name);
                   ps.setString(3, departa[i]);
                   ps.setString(4, email[i]);
                   ps.addBatch();
              ps.setString(4,uid);
              int[] results = ps.executeBatch();
              Statement stmt1=con.createStatement();
              ResultSet rsq=stmt1.executeQuery("SELECT name AS name1 from mailaddress where mail_userid=" + "'" + uid + "'" + ";");
              if(rsq.next()){
                   for (int i=0;i<name.length;i++) {
                   name[i] = rsq.getString("name1");
                   rsq.next();
    } catch (Exception e) {
                   throw new ServletException(e);
              } finally {
                   try {
                        if(rs != null) {
                             rs.close();
                             rs = null;
                        if(con != null) {
                             con.close();
                             con = null;
                   } catch (SQLException e) {}
    %>
    </html>
    <%
    %>

    Where exactly is the exception being generated?
    My guess is this bit here:
    if(rsq.next()){
      for (int i=0;i<name.length;i++) {
        name = rsq.getString("name1");
        rsq.next();
    }I don't think your name array has been initialised in this file. Plus it assumes that the name array has exactly the same number of items as the query returns. To me thats rather dubious...
    I would suggest this instead
    while (rsq.next()){
        name = rsq.getString("name");
    }I'm still not entirely certain what you are trying to accomplish, but thats probably the cause of the null pointer.
    good luck,
    evnafets

  • Graphical vs Raw Display

    I'm sending my output to a spool request.  When I look at it online in the "Graphical" display, a sample of a line is below:
    JOEXX
    4569878
    STAT44
    I'm using a pipe as a delimiter.
    When I switch to "Raw" display, the same line as above looks like what is below:
    #5JOEXX#54569878#5STAT44#5
    The pipe delimiter displays as #5.
    Is there a way to get around this where my pipe delimiter shows in the "Raw" Display or another delimiter that will display in both display mode?
    Any help would be appriciated,

    It is not possible, as I have created one spool of the standard transaction SM51 and tried to see in the RAW Display.
    the output was the same...#5 for pipe, #4 for horizontal line
    #COL0N#COL0H#0#4#4#4#4#4#4#4#4#4#4#4#4#4
    #COL1H#5    No Ty.  PID      Status   Re
    #6#4#4#4#4#4#4#4#4#4#4#4#4#4#4#4#4#4#4#4
    #COL0H#5#? #COL4H  0  #COL2NDIA  508154
    #5#COL0N#? #COL4H  1  #COL2NDIA  504056
    #5#COL0N#? #COL4H  2  #COL2NDIA  421970
    #5#COL0N#? #COL4H  3  #COL2NDIA  528390
    Sorry..
    Regards,
    Naimesh Patel

Maybe you are looking for