CSV produces a number

since I didn't get any conclusion from this thread, I decided to open a new one.
[ref: http://forum.java.sun.com/thread.jspa?threadID=5194217]
I have a CSV file in which I would like to write the STRING 0607 but for some reason the output comes as: 607
Does anyone know any CSV API that state that the value is a STRING and not a NUMBER?
thanks
Code:
     public static void produceCSVjv(String path, String fileName) throws IOException
          FileWriter writeCSV = new FileWriter(path+"/"+fileName);
          PrintWriter fileOutput = new PrintWriter(writeCSV);     
          fileOutput.println("\"0607 \"");  //result 607
                fileOutput.println("0607"); //result 607
          fileOutput.close();          
     }

import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
public class CSV
     public static void main(String args[]) throws IOException
          PrintWriter fileOutput = new PrintWriter(new FileWriter("testMyCsv.csv"));     
          fileOutput.println("\"0607\"");
          fileOutput.println("0607");
          fileOutput.close();     
}

Similar Messages

  • I have produced a number of DVD on my iMac. They are stored in a folder called Burn Folder. I want to get them into iTunes so I can play them on Apple TV. I have tried to convert them to MP4s using Handbrake but Handbrake does not recognize these files.

    I have produced a number of DVD on my iMac. They are stored in a folder called Burn Folder. I want to get them into iTunes so I can play them on Apple TV. I have tried to convert them to MP4s using Handbrake but Handbrake does not recognize these files. I am stumped.

    If you have the original movie files, you'd be much better converting those, otherwise try MPEGstreamclip.

  • Uploading csv file with number type data to database using apex

    hi
    am trying to upload csv file to oracle database using apex when i select the file using file browser and click on the button.
    my table looks like
    coloumn type
    col1 number(2)
    col2 number(2)
    col3 number(2)
    col4 number(2)
    please tell me the steps i need to follow
    urgent requirement

    This thread should help - Load CSV file into a table when a button is clicked by the user

  • I'm producing 'invalid NUMBER OF arguements' - but where?

    afternoon gurus..
    This line was bringing a 'ORA-00932: inconsistent datatypes: expected DATE got NUMBER' WHEN it was this..
    , DECODE(SIGN(TRUNC(apid.accounting_date)- TRUNC('14-jun-2011')),1,0, ROUND(NVL(apid.quantity_invoiced,0),2) )
    ,apid.accounting_date, NVL(apid.quantity_invoiced,0)
    ..so I added a 'to_date' TO it..
    , DECODE(SIGN(TRUNC(apid.accounting_date)- TRUNC(TO_DATE('14-jun-2011','dd-mon-yyyy')),1,0, ROUND(NVL(apid.quantity_invoiced,0),2) )
    ,apid.accounting_date, NVL(apid.quantity_invoiced,0)
    ..AND it now produces THE 'invalid NUMBER OF arguements' message..
    how DO I get OVER this please?
    TIA..
    Joe

    Missing a bracket I think...
    DECODE(SIGN(TRUNC(apid.accounting_date)- TRUNC(TO_DATE('14-jun-2011','dd-mon-yyyy')),1,0, ROUND(NVL(apid.quantity_invoiced,0),2) )should be
    DECODE(SIGN(TRUNC(apid.accounting_date)-TRUNC(TO_DATE('14-jun-2011','dd-mon-yyyy'))),1,0, ROUND(NVL(apid.quantity_invoiced,0),2) )

  • Logic to import data from n number of CSV to n number of tables dynamically

    I have C:/source folder which would contain n of csv files. 
    Suppose, I have 2 CSV files in this folder
    I need to select first CSV and put all records into first SQL table and then same for 2nd CSV (from 2nd CSV to 2nd table) 
    I don't know no of columns & column details of CSV. 
    How can we achieve it? which all tasks can we use?
    Note: I tried to use for each task.. and DFT inside it.. but I am confused how to use destination table task
    -Vaibhav Chaudhari

    Hi Vaibhav,
    The standard Data Flow Task supports only static metadata defined at runtime. What this means is that you have to create separate SSIS package for each CSV layout. This design is inefficient and requires more maintenance effort.
    If you can use third-party solutions, I would recommend you check the commercial COZYROC
    Data Flow Task Plus. It is an extension of the standard Data Flow Task with support for dynamic metadata at runtime. You can process source and destinations with different number of columns
    and order. No programming skills are required.
    SSIS Tasks Components Scripts Services | http://www.cozyroc.com/

  • 10g exporting to CSV using client_text_io is not working correctly.

    I have an odd issue which i could do with some help with. I run an function that exports to CSV based on an pre defined record group.
    This has been working fine for many months with various customers. Recently a new customer used it and they have 28k rows in his record group and the export is actually not exporting correctly.
    The record group has a record count of 28331.
    The CSV produced has only 3756 in my CSV file. These are the last 3756 records in the Record group so its as if its overwriting the data as it goes yet all smaller datasets work
    FUNCTION fun_export_csv (vgraphid NUMBER, p_filename VARCHAR2)RETURN BOOLEAN IS
      out_file                      client_text_io.file_type; 
         i                                             NUMBER;
      lv_line              VARCHAR2(5000);
    BEGIN
    rg:=populate_group('RG11_EXP');               
    synchronize;
    lv_line:= ('"GIN","Gin Date","PO Num","PO Required Date","Mat Num","Mat Description","Supplier Part No","On Time Delivery(Yes-1, No-0)"');
    client_text_io.put(out_file, lv_line);
    client_text_io.new_line(out_file,1); 
    For i in 1..get_group_row_count('RG11_EXP') Loop--this count is 28331
    lv_line:= ('"'||get_group_number_cell('RG11_EXP.col1', i )                 ||'"'|| ',' ||'"'||
         get_group_date_cell('RG11_EXP.grn_date', i )                 ||'"'|| ',' ||'"'||                                          
         get_group_number_cell('RG11_EXP.po', i )       ||'"'|| ',' ||'"'||
         get_group_date_cell('RG11_EXP.daterqd', i ) ||'"'|| ',' ||'"'||
         get_group_char_cell('RG11_EXP.item_no', i ) ||'"'|| ',' ||'"'||
         get_group_char_cell('RG11_EXP.desc', i )                    ||'"'|| ',' ||'"'||
         get_group_char_cell('RG11_EXP.part_no', i )               ||'"'|| ',' ||'"'||
         get_group_number_cell('RG11_EXP.ontime', i )                    ||'"');
    client_text_io.put(out_file, lv_line);
    client_text_io.new_line(out_file,1); 
    END LOOP;     
    client_text_io.FCLOSE(out_file);
    RETURN TRUE;          

    Hello,
    Try to insert a "synchronize" instruction from time to time:
    i  pls_integer := 1;
    Loop
      If mod(i, 500) = 0 Then
         synchronize;
      End if ;
      i := i + 1 ;
    End loop;
    ...<p>But keep in mind the the CLIENT_TEXT_IO generate a lot of network traffic, so it is better and faster to generate the file on the A.S., then after transfer it to the client machine.</p>
    Francois

  • ORA-01722: invalid number

    Hi,[email protected]
    we are working on Import tool, which takes a CSV file and inserts in Oracle
    DB.I am using PLSQL UTL_File.Please look into the PLSQL file and clarify my
    Queries.
    If the Last column is a Varchar field, we are able to insert Records
    comfortably. but we get the Following Error when the last column in CSV file
    is a Number field.
    Error Generated:
    ORA-01722: invalid number 12242, ,
    Praveen, Reddy, Chitti, Praveen Reddy Chitti, ,700,
    ORA-01722: invalid number 12242, ,
    Abhishek, C, Singh, Abhishek C Singh, ,700,
    ORA-01722: invalid number 12243, , Paul,
    K, Jak, Paul K Jak, ,700,
    15 ORA-01722: invalid number 12242, ,
    Praveen, Reddy, Chitti, Praveen Reddy Chitti, ,700,
    Expecting reply from u in this regard.
    Regards,
    Mahi
    Sample table Structure:
    CREATE TABLE EMPM(
    CMPCD NUMBER (10) NOT NULL,
    LCTCD NUMBER (10),
    EMPCD NUMBER (10) NOT NULL,
    REFNO VARCHAR2 (51),
    USRID NUMBER (10),
    PREFX VARCHAR2 (10),
    FNAME VARCHAR2 (51) NOT NULL,
    MNAME VARCHAR2 (51),
    LNAME VARCHAR2 (51) NOT NULL,
    FULNM VARCHAR2 (201) NOT NULL,
    EMPSX VARCHAR2 (1),
    SSNUM VARCHAR2 (16),
    NTLTY NUMBER (10),
    STSCD NUMBER (10),
    TCODE NUMBER (10),
    JDATE DATE,
    TDATE DATE,
    ACDOB DATE,
    ADATE DATE,
    DSGCD NUMBER (10),
    DPTCD NUMBER (10),
    MGRCD NUMBER (10),
    REFBY NUMBER (10),
    WPHON VARCHAR2 (25),
    MPHON VARCHAR2 (16),
    RPHON VARCHAR2 (16),
    PGRNO VARCHAR2 (16),
    WKFAX VARCHAR2 (16),
    RSFAX VARCHAR2 (16),
    WKEML VARCHAR2 (256),
    PEML1 VARCHAR2 (256),
    PRLN1 VARCHAR2 (256),
    PRLN2 VARCHAR2 (256),
    PRCCD VARCHAR2 (256),
    PRSCD NUMBER (10),
    PRSIN VARCHAR2 (51),
    PRCTR NUMBER (10),
    PRZIP VARCHAR2 (15),
    PMLN1 VARCHAR2 (256),
    PMLN2 VARCHAR2 (256),
    PMCCD VARCHAR2 (256),
    PMSCD NUMBER (10),
    PMSIN VARCHAR2 (51),
    PMCTR NUMBER (10),
    PMZIP VARCHAR2 (15),
    LOADN NUMBER (10),
    RESF1 VARCHAR2 (256),
    RESF2 VARCHAR2 (256),
    RESF3 VARCHAR2 (256),
    RESF4 VARCHAR2 (256),
    RESF5 VARCHAR2 (256),
    OWNER VARCHAR2 (4000),
    NOTES VARCHAR2 (401),
    DFLAG VARCHAR2 (10) DEFAULT '0' NOT NULL,
    MODBY NUMBER (10) NOT NULL,
    MODON DATE NOT NULL,
    PRIMARY KEY("CMPCD", "EMPCD"))

    we get the Following Error when the last column in CSV fileis a Number field.
    Clearly one or more records has a value in the last column that is non-numeric. Broadly speaking, a number consists of characters 0123456789, with optional minus sign and decimal point (scientific notation is also allowed). Just about anything else is not a number. 934-89 is not a number. 786.567.765 is not a number. A NULL should not throw ORA-1722 but spaces will.
    So, check your data. You find it necessary to employ an intermediary table and cleanse the data there. Alternatively, yell at the people who produce the extract. Or change your schema definition. Whatever's right.
    Cheers, APC

  • Sequential numbers in non-buffered number range object

    I need some help pointing in the right direction to analyze and prevent a problem with a NON-BUFFERED custom number range object.
    This process works well.  Once or twice however, sequences have been created with an apparent delay and are out of order.  I don't know why, or where to look to diagnose the timing, etc.  It's very difficult to recreate.
    We have a custom number range object; ZFSEQ in SNRO that is responsible for assigning a sequential number to a series of flat files produced by number of different interfaces.  Those interfaces all use the FM  'NUMBER_GET_NEXT' and then they build a file name with that sequence number.  That object is not buffered.
    During heavy volume of updates (where lots of these sequences are being called and created by different interfaces, the table NRIV is locked and released by each interface.  During this time of heavy updates, we have an infrequent problem that has occurred where a standard sales order create created a sequence number that is greater than the sequence number generated by the delivery create.  (The delivery was created a couple of minutes later than the order, yet the order created a flat file sequence number greater than that of the delivery.
    I hypothesize that the flat file call for the order (using the  FM  'NUMBER_GET_NEXT') was somehow delayed(because of heavy lock/usage of NRIV).  The actual order document and delivery document were created normally.  I also am thinking that buffering on the object would prevent this.  I cannot at this time implement buffering on the object, but we are working towards that.
    The order create originates from our e-commerce system through a webserive, and in SAP, flows like this:
    Main webservice RFC:     Z_ORDER_CREATE
              Call Z_create_order_bgd  IN BACKGROUND TASK
                                      Call BAPI_SALESORDER_CREATEFROMDAT2 )
                                       MV45AFZZ--> userexit_save_document.
                                            call Z_FUNCTION_TO_GET_SEQUENCE
                                                      CALL FM  'NUMBER_GET_NEXT'    <---- order create sequential file created
              commit work.
    The delivery sequential file is created in
         MV50AFZ1  (the Delivery User Exit)
    Where can I look to conclusively see what happened to delay our sales order sequence?  What could be done to prevent it?
    Thanks
    Jeremy H.

    Just want to post the answer that we found to this issue and close it, though more comments are always welcome!
    We are going to move forward with buffering the Z object for the range as studies have shown and all other consulting input seems to be that buffering will solve this problem.

  • Header and footer on a csv download

    Hi
    Is there an easy way to add an extra header and footer to a csv download ?
    What the user wants is a csv of the format
    New heading --- the additional heading
    col name, col name ..... -- the existing column names
    value, value ..... -- the existing values
    New footer -- some new text footer
    I have tried break formatting but have had no success. The csv produces perfectly but I can't get the additional lines added !
    Ta
    Bob

    No unfortunately I have not found the time to do a blog yet.
    Create a blank page and create an AFTER HEADER pl/sql process.
    Then add code like the following, changing query as needed
    declare
       cursor result_cur is
          select empno, ename, job
            from emp;
    begin
       htp.init; -- Wipe out the buffer
       owa_util.mime_header ('application/excel',false);
       htp.p('Content-Disposition: attachment; filename="FormResults.csv"');
       owa_util.http_header_close;
       -- write your header
       htp.p('This is my header');
       htp.p(' ');
       -- write out the column names
       htp.print ( 'Emp Num, Employee Name, Job' );
       --write out each row
       for it in result_cur loop
          htp.print ( '"'||it.empno||'","'||it.ename||'","'||it.job||'"' );
       end loop;
       -- write out footer
       htp.p(' ');
       htp.p('This is my footer');
       -- Send an error code so that the
       -- rest of the HTML does not render
       htmldb__application.g_unrecoverable_error := true;
    end;you can call this by making it the redirect target of a button or by adding something like the following in the footer section of your report region assuming the page you created the above process on was page 9
    <a href="f?p=APP_ID.:9:&SESSION.">Click here to download CSV</a>sorry the code above shows a # and does not show the f p syntax url which should be f followed by a ?p=&AMP;APP_ID.:9&AMP;:SESSION.
    Edited by: Larry Linnemeyer on May 20, 2009 8:08 AM

  • ORA-01722: invalid number caused with SQL using bind variable

    Hi,
    Im am hoping that someone can help me resolve a problem thats only just services and is being experienced on quite a few clients.
    our application uses C++ exes and makes OCI calls to the database.
    what has happened in the last week or so, there has been quite a few invalid number errors being received on a prod server but strangly enough we cannot reproduct the error on our UAT system.
    The sql is using bind variables and the information in the trace file shows that a number is being used for the bind variable, here is an extract from one trace file:
    for some schemas, the bind variable value is some currupted value, i think:
    oacdty=01 mxl=32(21) mxlc=00 mal=00 scl=00 pre=00
    oacflg=03 fl2=1206001 frm=01 csi=178 siz=32 off=0
    kxsbbbfp=9a8d62b8 bln=32 avl=03 flg=05
    value="Â*d"
    but on another schema, the value used is:
    Bind#0
    oacdty=01 mxl=32(32) mxlc=00 mal=00 scl=00 pre=00
    oacflg=03 fl2=1206001 frm=01 csi=178 siz=32 off=0
    kxsbbbfp=c5f92718 bln=32 avl=04 flg=05
    value="2101"
    however both produce invalid number errors.
    I am relatively inexperienced as a DBA so would appreciate as much help as i can get.

    Could you post your sql statement that is being run.
    Also post the query plan from your uat system and the one from your production system (They are likely to be different)
    You can export the stats from your production system and run them in your uat system. If you do this, then the execution plans should be the same on both systems(dbms_stats) and if you have the same data you should run into the same problem on uat as in production.
    The root cause of this type of problem is having a column in a table which holds values which are of different datatypes. Typically there is a condition in the where clause which indicates that for example only numeric columns should be retrieved from the column which holds multiple data types. However since the optimizer is free to rewrite the query any way it sees fit, (It does not necessarily execute in the order the sql statement is written) it does not filter this data first, and therefore you hit non-numeric data and run into the invalid number error.
    You can use little techniques like using an inline view with rownum in the column list, to perform the first filter. This ensures that the inline view is executed on its own, rather than being merged (materialized) with the rest of the query.
    A quick temporary solution is to use a comparison like to_char(column_name) = variable
    Make sure your comparisons are correct and it doesn't negatively impact on performance of the query

  • VAT Number link to Customer tax clasification

    Dear All,
    Give your some inputs on VAT number and Customer tax classifications for MWST determination in sales order,
    Please check sales orders in scenrio's
    1. VAT number not given in customer master  in general data - Sold to party.
    SON - 1 where MWST is 0 %, customer tax classification is "0" condition record found  - Sale org/plant/destination country/cust tax clas/mat tax clas
    2500/1000/FR/0/1 - 0 %
    2. VAT number is given in customer master in general data - Sold to party
    SON - 2, Where MWST is 19.6 %, customer tax classification is "1" condition record found - Sale org/plant/destination country/cust tax clas/mat tax clas
    2500/1000/FR/1/1 - 19.6 %
    Where can i check that link between VAT number and customer tax clasification?
    Regards
    Ramakrishna.P

    Hi
    In fact there is no link between VAT number and customer tax classification. See my explanation below
    1. Customer tax classfication is used to determine whether the customer should be taxable or not together with tax codes maintained in FTXP. For e-g Cust tax classification 0 means no tax which is why in your first case there was no tax in the sales order. In your second sales order, cust tax classification was "1" which means full tax and that is the reason your second sales order had outout tax 19.6%. Condition records for taxes are maintained like this (please mind that this is only an example, there could be several access sequences maintained as per the business requirement)....Tax classification 1 then tax code say U1 which means 19.6%, Tax classification 0 then tax code A0 which means 0% tax.
    2. Now coming to the VAT number. This is generally filled in the customer master control data to print it on the invoices. VAT number is more of a legal procedure that this is checked when there is a movement of goods. So if you have a look at European invoices, you will find both seller's and buyer's VAT numbers on the invoice. Secondly, VAT number also exempts VAT for the buyer if the both the transaction occurs within the EU and only if the buyer produces VAT number while placing the order or may be before invoicing is done.
    Hope this helps
    Thanks
    Chandra Kiran

  • 1180: Call to a possibly undefined method produce.

    package{
        import flash.display.MovieClip
        import flash.display.MovieClip
        import flash.events.Event
        import flash.events.MouseEvent
        import flash.events.KeyboardEvent
        import flash.ui.Keyboard
        public class arrayagain extends MovieClip{
            var arrObj:Array = new Array( "mcDog", "mcElephant", "mcDog", "mcCat", "mcHippo", "mcLion" );
            var enemy:Array = new Array();
            var mc:MovieClip;
        produce(5);
        function produce(num:Number):void {
            for( var i:Number = 0; i < num; i++ ) {
                var ran:int = Math.random() * arrObj.length;
                mc = new (getDefinitionByName( arrObj[ran] ) as Class)();
                mc.x = 100 + (mc.width * i) + 50;
                mc.y += 9;
                enemy.push( mc );
                addChild( enemy[i] );
    What is the problem can somebody help me plss....

    You have the call to produce outside of any method... you can't do that in classes.
    Use:
    package{
        import flash.display.MovieClip
        import flash.display.MovieClip
        import flash.events.Event
        import flash.events.MouseEvent
        import flash.events.KeyboardEvent
        import flash.ui.Keyboard
        public class arrayagain extends MovieClip{
            var arrObj:Array = new Array( "mcDog", "mcElephant", "mcDog", "mcCat", "mcHippo", "mcLion" );
            var enemy:Array = new Array();
            var mc:MovieClip;
        public function arrayagain(){
             produce(5);
        function produce(num:Number):void {
            for( var i:Number = 0; i < num; i++ ) {
                var ran:int = Math.random() * arrObj.length;
                mc = new (getDefinitionByName( arrObj[ran] ) as Class)();
                mc.x = 100 + (mc.width * i) + 50;
                mc.y += 9;
                enemy.push( mc );
                addChild( enemy[i] );

  • How to type in one number do a LOOKUP function on that number.

    I want to be able to type in a number in one cell. I want the LOOKUP function to find that number in a column and produce another number in a corresponding column.
    I want to type in a number in A1. Then in another cell lookup the number in A1 in b1:b40 and then display the corresponding number in c1:c40.
    I want something like this...
    =LOOKUP(A1, B1:B40, C1:C40)
    Thanks

    Your lookup function looks in B1:B40 to find a match to the number in A1 and returns with the corresponding value from C1:C40. Typically, B1:40 and C1:C40 would be in another table (i.e., a lookup table) and this function would be in the original table next to A1.
    Cell B1 = LOOKUP(A1, Table 2::B1:B40,Table 2::C1:C40)

  • Can only bring some CSV's online on one specific host

    Hi.
    I have a three node Hyper-V (2012 R2) cluster.
    It has 12 CSV's connected. Two of the CSV's can only be brought online on one of the hosts. It seems, they are locked to that host in some way.
    The end result is that when I take that host down for maintenance, the two CSV's go offline and all VM's on them, crash.
    I suspect a particular VM of causing this but I don't know how to fix the problem.
    Anyone?
    Thanks in advance.
    /Michael

    What size are the CSV and is the storage connected via iSCSI, Fibre or SMB?
    If Fibre or iSCSI, check that the SAN is configured to allows all three hosts to connect to the storage group and each has access to all LUNS from a SAN point of view. If iSCSI check the Initiator and the MPIO settings on all three host etc.
    With regards to the Access denied, have a scan through this link it maybe of help and check if the VM worker process (VMMS) has the relevant permissions on the CSV volume. 
    http://blogs.technet.com/b/askcore/archive/2014/10/01/virtual-machine-checkpoint-fails-with-access-denied-when-running-on-a-clustered-shared-volume.aspx
    If possible, I think i would attempt to move the VMs of the storage, remove and re-present it or increase the size of the other CSV. The number of CSV is down to design, connections the SAN can support and various other things and although 12 is a lot of
    CSV for three nodes, as mentioned above it should work and there are many cluster with a lot more.
    I know its a pain, but I would really try to run the validation wizard to check widows updates match etc. Also have you checked all firmware updates for HBAs or NICs etc?
    Kind Regards
    Michael Coutanche
    Blog:Twitter:LinkedIn:
    Note: Posts are provided “AS IS” without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

  • Old Producer/Consumer Example question

    how would I take this code, the old producer/consumer example, and make it for 2 consumers and 1 producer?
    basically, like this:
    Producer put 1
    Consumer #1 got 1
    Consumer #2 got 1
    Producer put 2
    Consumer #1 got 2
    Consumer #2 got 2
    etc.....
    ***********Producer.java***************
    public class Producer extends Thread {
    private CubbyHole cubbyhole;
    private int number;
    public Producer(CubbyHole c, int number) {
    cubbyhole = c;
    this.number = number;
    public void run() {
    for (int i = 0; i < 10; i++) {
    cubbyhole.put(i);
    System.out.println("Producer #" + this.number
    + " put: " + i);
    try {
    sleep((int)(Math.random() * 100));
    } catch (InterruptedException e) { }
    ***********Consumer.java***********
    public class Consumer extends Thread {
    private CubbyHole cubbyhole;
    private int number;
    public Consumer(CubbyHole c, int number) {
    cubbyhole = c;
    this.number = number;
    public void run() {
    int value = 0;
    for (int i = 0; i < 10; i++) {
    value = cubbyhole.get();
    System.out.println("Consumer #" + this.number
    + " got: " + value);
    ***********CubbyHole.java***********
    public class CubbyHole {
    private int contents;
    private boolean available = false;
    public synchronized int get() {
    while (available == false) {
    try {
    wait();
    } catch (InterruptedException e) { }
    available = false;
    notifyAll();
    return contents;
    public synchronized void put(int value) {
    while (available == true) {
    try {
    wait();
    } catch (InterruptedException e) { }
    contents = value;
    available = true;
    notifyAll();
    ***********ProducerConsumerTest.java***********
    public class ProducerConsumerTest {
    public static void main(String[] args) {
    CubbyHole c = new CubbyHole();
    Producer p1 = new Producer(c, 1);
    Consumer c1 = new Consumer(c, 1);
    p1.start();
    c1.start();

    instantiate another consumer.
    public class ProducerConsumerTest {
    public static void main(String[] args) {
    CubbyHole c = new CubbyHole();
    Producer p1 = new Producer(c, 1);
    Consumer c1 = new Consumer(c, 1);
    Consumer c2 = new Consumer(c, 2);
    p1.start();
    c1.start();
    c2.start();
    but then modify CubbyHole so that it checks that it has been consumed twice (as thats what you want, you said). Instead of using boolean available, use an integer flag that counts how many times its been consumed, and then reset the flag when it gets to 2. Something like that. Is this a college question? Do your homework. ha ha.

Maybe you are looking for