Getting multiple notepad out put files

hello
i'm trying to make a java program that writes out multiple files to a folder in my documents. However, i'm confused on how to make a for statement that would output a lot of files, while making them still write and not have to replace the previous one.......
this is my program
import java.io.*;
public class notePad{
public static void main(String args[]){
try{
File infile = new File("C:/Documents and Settings/c1s5/My Documents/Allah/sample.txt");
FileOutputStream fos = new FileOutputStream(infile);
PrintWriter out = new PrintWriter(fos);
out.println("This is the sample text in the notepad");
out.flush();
out.close();
}catch(Exception e){}
and i want to be able to manipulate the sample so that it goes sample 1...sample 2..for every time it runs though the for statement....also, i want to make it output more than one file....anyone have an idea how i can do this...its my fourth month in java...so i'm a noob
hwrd

import java.io.*;
public class notePad{
  public static void main(String args[]){
    try{
      for(int i=0; i<how many file; i++)
        File infile = new File("C:/Documents and
        Settings/c1s5/My Documents/Allah/sample.txt" + i);
        FileOutputStream fos = new FileOutputStream(infile);
        PrintWriter out = new PrintWriter(fos);
        out.println("This is the sample text in the
        notepad");
        out.flush();
        out.close();
    }catch(Exception e){}
Change the file name for each one. as long as you use the same hard coded file name it will overwrite the previous one. The example is hideous and very rought but should give you the idea.
Hope this helps,
PS.

Similar Messages

  • How should we get the out put file-name same as in put file-name in file to

    Hi frnds,
    having hundreds of files in the sender system with different names, how should we get the out put file-name  in the receiver system same as the in put file-name in file to file scenario ?
    Thanks in advance.
    truly,
    snrvakiti.

    Hi,
    In Receiver File Adapter you can set under 'Adapter-Specific Message Properties'
    check Use Adapter-Specific Message Properties
    check Fail on Missing Adapter Message Properties
    Check File Name
    Have a look at this link,  [File_to_File|http://allsapnetweavernotes.blogspot.com/2008/09/how-can-i-access-filename-from-fileftp.html]
    Regards,
    P.Rajesh

  • Out put file is not genrated when calling xml reports from OAF page

    Dear all
    i am calling xml reports from OAF page
    the out put file is not generated
    i am writing this code
    public int tradingrequest(String quoid, String costoder,int orgid)
    try
    OADBTransaction tx = (OADBTransaction)getOADBTransaction();
    java.sql.Connection pConncection = tx.getJdbcConnection();
    ConcurrentRequest cr = new ConcurrentRequest(pConncection);
    String applnName =
    "XXCRM"; //Application that contains the concurrent program
    String cpName = "XXCRM_COSTSHEET"; //Concurrent program short name
    String cpDesc =
    "Trading Costsheet Report XXCRM"; // concurrent Program description
    Number orgid1=new Number(orgid);
    // Pass the Arguments using vector
    Vector cpArgs = new Vector();
    cpArgs.addElement(quoid);
    cpArgs.addElement(costoder);
    cpArgs.addElement(orgid1.toString());
    // Calling the Concurrent Program
    int requestId =
    cr.submitRequest(applnName, cpName, cpDesc, null, false, cpArgs);
    tx.commit();
    System.out.println("Request ID is " + requestId);
    return requestId;
    } catch (RequestSubmissionException e)
    OAException oe = new OAException(e.getMessage());
    oe.setApplicationModule(this);
    throw oe;
    in controller i am writing this code
    OAMessageStyledTextBean y =
    (OAMessageStyledTextBean)webBean.findChildRecursive("quotationid");
    OAFormValueBean z =
    (OAFormValueBean)webBean.findChildRecursive("costorder");
    String quoid = y.getValue(pageContext).toString();
    String costorder = z.getValue(pageContext).toString();
    System.out.println("The quotation id and costing order are....." + quoid +
    " " + costorder);
    /*if click on run report button to run the report*/
    if ("Viewreport".equals(pageContext.getParameter(EVENT_PARAM)))
    if (tsflag.equals("Y"))
    int requestid = am.servicerequest(quoid, costorder, orgid);
    String url =
    "OA.jsp?akRegionCode=FNDCPREQUESTVIEWPAGE&akRegionApplicationId=0&retainAM=Y&addBreadCrumb=Y&REQUESTID=" +
    requestid;
    pageContext.setForwardURL(url, null,
    OAWebBeanConstants.KEEP_MENU_CONTEXT, null,
    null, true,
    OAWebBeanConstants.ADD_BREAD_CRUMB_YES,
    OAWebBeanConstants.IGNORE_MESSAGES);
    when i call the report from oaf page the request id is coming
    when i click on view output i am getting this message
    Error
    The concurrent request 7335031 did not create an output file.
    WHEN I GOTO FIND REQUESTS PAGE QUERY THIS REQUEST ID I AM GETTING THE OUTPUT IN XM FILE
    Regards
    Sreekanth

    java.io.FileNotFoundException: \..\..\..\xdoAqdFFZfuuJ051010_0628487460.fo (The system cannot find the path specified)
    MY CO code
    if("GenerateReport".equals(event))
    // Get the HttpServletResponse object from the PageContext. The report output is written to HttpServletResponse.
    DataObject sessionDictionary = (DataObject)pageContext.getNamedDataObject("_SessionParameters");
    HttpServletResponse response = (HttpServletResponse)sessionDictionary.selectValue(null,"HttpServletResponse");
    try {
    // Hashtable hashtable = new Hashtable(1);
    // hashtable.put("TruckBookingRefNum",trucknum);
    // System.out.println("test"+trucknum);
    ServletOutputStream os = response.getOutputStream();
    // Set the Output Report File Name and Content Type
    String contentDisposition = "attachment;filename=LF Cargo Summary Report.htm";
    response.setHeader("Content-Disposition",contentDisposition);
    response.setContentType("application/HTML");
    // Get the Data XML File as the XMLNode
    XMLNode xmlNode = (XMLNode) am.invokeMethod("getTestDataXML");
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    xmlNode.print(outputStream);
    ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
    ByteArrayOutputStream pdfFile = new ByteArrayOutputStream();
    System.out.println(" ByteArrayInputStream.ByteArrayOutputStream"+pdfFile+inputStream);
    //Generate the PDF Report.
    TemplateHelper.processTemplate(
    ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getAppsContext(),
    "LFCUST",
    "XXLFCARSUM_TARGET",
    "English",//((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getLanguage(),
    "US",//((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getCountry(),
    inputStream,
    TemplateHelper.OUTPUT_TYPE_HTML,
    null,
    pdfFile);
    // hashtable);
    System.out.println(" TemplateHelper");
    // Write the PDF Report to the HttpServletResponse object and flush.
    byte[] b = pdfFile.toByteArray();
    System.out.println(" byte"+b);
    response.setContentLength(b.length);
    os.write(b, 0, b.length);
    os.flush();
    os.close();
    pdfFile.flush();
    pdfFile.close();
    catch(Exception e)
    System.out.println(" inside catch");
    response.setContentType("text/html");
    throw new OAException(e.getMessage(), OAException.ERROR);
    pageContext.setDocumentRendered(true);
    Edited by: user9367919 on May 13, 2010 10:31 AM

  • Out put file with three extra blank line

    Hi Expert
    i am snding some article data from sap to ftp location.from proxy class the internal table has all correct record .but in the out put file three blank line is coming with all the record at the end.
    i have the following cc parameter
    File.fieldNames Trans_type,Transfer_no,SrcSt_no,DestST_no,LPN_No,Transfer_date
    File.fieldFixedLengths 1,30,10,10,10,8
    then i added
    File.endSeparator '0'.
    but still 3 blank line is coming in the output file.
    please suggest somthing.

    Hi !
    Why are you using File.endSeparator '0'. ?
    Are you sure your input data doesn't have those 3 blank records in the end? Check the message payload in the sxmb_moni transaction.
    Regards,
    Matias.

  • Special charactors found in out put file of .xml file in file adapter

    Hi ,
    Dear all,
    I am working on Sender File adapter picking files from the multiple Directories which are specified in a single CC and these files are placed in the different receiver directories in different CC's metained paths of the receivers
    The Souce is XML.
    When I use  the receiver format as .csv,.txt it the out put is as excepted,when i give the receiver format as .XML the output file contents:PK   (An invalid character was found in text content. Error processing resource 'file:).
    Pl let me know how to tackle thsi situation.
    Thanks,
    Srini

    Hi
    Also try with the following UDF.
    public class XmlUtil {
        char[] specialCharacters = { '&', '<'>', '\'' };
        String[] replacementStrings = { "&", "<">", "&apos;" };
        public static String sanitizeText( String text ) {
            StringBuffer buffer = new StringBuffer( text );
            for( int i = 0; i < buffer.length(); i++ ) {
                for( int k = 0; i < specialCharacters.length; k++ ) {
                    if( buffer.charAt(i) == specialCharacters[k] ) ) {
                         buffer.replace( i, i + 1, replacementString[k] );
                         i += replaceString[k].length;
                    } else if( (int)buffer.charAt(i) > 128 ) {
                         String replacement = "&#" + (int)buffer.charAt(i) + ";";
                         buffer.replace( i, i + 1, replacement );
                         i += replacement.length();
            return buffer.toString();
    Regards
    Abhishek Mahajan

  • Out put file is not coming

    Hi all,
    if user is l running one report and it will run successfully.
    then my doubt is at that time output will not generate.
    At that time what i will do?
    and suppose out put will button is disable .then what i will do at that time?
    regards.
    vijay

    Hi follow the following thread...this thread topic is more or less same...If the issue is resolved, you will come to know how to debug this type of issues....
    output file
    output file

  • How to get the table out put

    Hi
    I have a function in a package where it's out put is a table.
    I call it from FORM level procedure.
    Could anybody help me with view the data of my out put for the purpose of debugging.
    (Note: I use SQL Navigator as the db tool , Forms Builder (9.0.4.2.0))
    Rgds
    shabar

    I don't exactly know how your datablock is, the aray you are returning but you can use code like this to populate the data block.
    Write this code in when new form instance trigger.
    declare
      type pkarray is varray(100) of <table_name>.<column_name>%type; --table name on which your varray returning from function is based.
      id_arr pkarray := pkarray();
    begin
      id_arr := <function_name>; -- call to your function which returns the array
      go_block('<block_name>');
      clear_record;
      first_record;
       For i in 1..id_arr.count
       loop
           :<block_name>.<item_name> :=  id_arr(i);
           next_record;
       end loop; 
    end;You can tweak this code to suit your requirement.
    Hope it helps.
    Please mark answer as helpful / correct, if it helps you
    Navnit

  • How do I get data to be written to an out put file at a timed increment?

    I am trying to get Labview to record a voltage and write to a text file at given increments but I am new at this and do not know how to program this in labview.  I would appreciate any guidance or code/examples that would be helpful. 

    Like this then...
    Attachments:
    Time_elapsed.jpg ‏26 KB

  • To get the the out put of the procedure..help needed

    hi all,
    i have a procedure :
    CREATE OR REPLACE PROCEDURE EN_GetCategory
         StaffID IN      VARCHAR2 DEFAULT NULL,
         ResultCategory OUT      VARCHAR2
    AS
    v_exec_tx varchar2(2000);
         Condition VARCHAR2(1000);
         Category VARCHAR2(1);
         SQL_ADV VARCHAR2(2000);
         Cnt          NUMBER(10);
         Cnt1          NUMBER(10);
    CURSOR curCategory IS
    SELECT SMC.Category,SMC.Condition FROM ST_MS_Category SMC ORDER BY OrderRowNo;
         BEGIN
              EXECUTE IMMEDIATE 'TRUNCATE TABLE TMP';
              OPEN curCategory;
              FETCH curCategory INTO Category, Condition;
              while curCategory%FOUND
              LOOP
              BEGIN
                   v_exec_tx:='SELECT COUNT(*) FROM ST_EMPLOYEE WHERE StaffID=''' || EN_GETCATEGORY.STAFFID ||''' AND ' || EN_GETCATEGORY.CONDITION;
                   EXECUTE IMMEDIATE v_exec_tx into Cnt;
    IF Cnt > 0 THEN                              SELECT COUNT(*) INTO CNT1 FROM tmp ;
              IF CNT1> 0     THEN
                                       UPDATE tmp SET CAT = Category ;
              ELSE
                                       INSERT INTO tmp VALUES (Category );
              END IF;
              END IF;
              FETCH curCategory INTO Category, Condition;
                   END;
              END LOOP;
              CLOSE curCategory;
              BEGIN
                   FOR REC IN ( SELECT CAT FROM tmp
                   LOOP
                   EN_GetCategory.ResultCategory := REC.CAT;
                   END LOOP;
              END;
         END;
    i need to execute this procedure..
    i tried EXEC EN_GETCATEGORY('812005','');
    but getting error invalid sql statemnt..
    i think for this we have to write some more code can u please help to to find the output ofthis procedure..
    Thanks In advance

    Hi,
    i tried EXEC EN_GETCATEGORY('812005','');It's execute Procedure_name('Parameters');
    Regds.What tosh! "exec" is perfectly ok to use to call a procedure.
    The problem is with the OUT parameter. You need to declare a variable into which the OUT value can be put.

  • Print PDF out put file

    Hi all
    I am using below to generate PDF output file
    String s3 = oapagecontext.getParameter("RtfTemplateName");
    //Generate the PDF Report.
    if ("PDF".equals(ReportOutputType))
    TemplateHelper.processTemplate(((OADBTransactionImpl)oapagecontext.getApplicationModule(oawebbean).getOADBTransaction()).getAppsContext(), "APP_NAME", s3, "en", "US", inputstream, (byte)1, (Properties)null, bytearrayoutputstream);
    is there any parameter or anything by which i can automatically print the PDF without having to actually click Print on the PDF file ??
    Please help
    Thanks

    Use Standard Program RSTXPDFT4 in SE38 / SA38 with Sppol Request Number to convert OTF Purchase Order Format to PDF Format.
    In order to send PO, your Basis team must configure the system first so that external email can be send out from SAP.  If it is not configured, no settings you do on MM will work.
    1. You must maintain email address in vendor master data.
    2. The same applies to your user master data.  For the output type for default values, a communication strategy needs 
    to be maintained in the Customizing that supports the e-mail. You can find the definition of the communication strategy in the 
    Customizing via the following path: 
    (SPRO -> IMG -> SAP Web Application Server -> Basic Services -> Message Control -> Define Communication Strategy). 
    As a default, communication strategy CS01 is delivered. This already contains the necessary entry for the external communication. Bear in mind that without a suitable communication strategy it is not possible to communicate with a partner via Medium 5 (external sending).
    3. Use the standard SAP environment (program 'SAPFM06P', FORM routine 'ENTRY_NEU' and form 'MEDRUCK') as the processing routines.
    4. In the condition records for the output type (for example, Transaction MN04), use medium '5' (External send).
    5. You can use Transaction SCOT to trigger the output manually. The prerequisite for a correct sending is that the node is set correctly. This is not described here, but it must have already been carried out.
    6. To be able to display, for example, the e-mail in Outlook, enter PDF as the format in the node.
    Regards,
    Ashok

  • Document currency in cube but not in the getting in query out put

    Hi Gurus,
    I am in production.... my query is regarding account receivable( which is user defined ie., is custom )  i am able to see amount in document currency in cube but is not appering when i excute the query ...
    And i am to get the output amount in local currency ( i am getting ) amount in document ( not getting )
    and revalution amount ( not getting )---- which is cal key fig 
    and finally   Amount FAS ( not getting ) ---  which is Restricted key fig
    Gurus Please suggest ..........

    Hi,
    The fields in the report
    customer
    HFC code
    doc Number
    business divison
    sales order
    country
    profit center
    customer number compounded with company code
    customer payment terms
    reference
    documennt type
    document date
    net due date
    G/L Account comp cpde
    item  Status
    Document currency
    Account in Local currency
    Amount  in Document currency
    filters are
    compay code
    controling area
    Business Division
    Free char
    Controling area
    account type
    clearing Doc Number
    Ref Key 2
    Fical year
    Fiscal year / period
    interunit / outside
    Posting Date
    Leading BD ( Wbs Attr)
    in rows
    customer
    doc number
    business divison
    sales order
    country
    profit center
    customer bumber compounded with company code
        under this we have customer payment terms
    Reference
    document type
    document date
    Net due date
    G/L Account Comp code
    item status
    Document Currency
    In columns
    i am selecting
    Amount  in local currency
    amount Document currency
    Revaluation amount
    Amount in FAS

  • Invalid characters found in the generated out put file

    hi ,
    I had written  a report to generate a file using open dataset , And In the generated file there are invalid characters generated for few fields. can any body help me with this.
    regards
    nelakonda

    Hi,
    Try below code.
    DATA : l_w_file LIKE rlgrap-filename .
      FIELD-SYMBOLS : <l_w_record> TYPE string,
                      <l_table>    TYPE STANDARD TABLE,
                      <l_line>     TYPE ANY,
                      <l_field>    TYPE ANY.
      DATA         : new_table TYPE REF TO data   ,
                     new_line  TYPE REF TO data   .
      TYPE-POOLS : slis.
      DATA      : wa_fieldcat             TYPE lvc_s_fcat         ,
                  wa_fieldcat1            TYPE slis_fieldcat_alv  ,
                  fieldcat                TYPE slis_t_fieldcat_alv,
                  gt_fieldcat             TYPE lvc_t_fcat         .
      DATA : l_w_length TYPE i.
      DATA : wa TYPE string.
      CLEAR : p_subrc .
      l_w_file = p_file .
      OPEN DATASET l_w_file FOR INPUT IN BINARY MODE.
      IF sy-subrc NE 0 .
        p_subrc = 1 .
        EXIT.
      ENDIF .
      ASSIGN wa TO <l_w_record> CASTING.
      DO.
        READ DATASET l_w_file INTO <l_w_record>.
        CONDENSE <l_w_record>.
        IF sy-subrc EQ 0.
        ELSE.
          EXIT.
        ENDIF.
        APPEND <l_w_record> TO p_it_itab.
    *This method will create a structure required for the
    *runtime table generation
        l_w_length = STRLEN( <l_w_record> ).
          CLEAR wa_fieldcat.
       wa_fieldcat-fieldname    =  wa.
       wa_fieldcat-seltext      =  wa.
          wa_fieldcat-outputlen    =  l_w_length          .
          APPEND wa_fieldcat       TO gt_fieldcat         .
          CALL METHOD cl_alv_table_create=>create_dynamic_table
            EXPORTING
                        I_STYLE_TABLE             =
              it_fieldcatalog           = gt_fieldcat
                        I_LENGTH_IN_BYTE          =
            IMPORTING
              ep_table                  = new_table
            EXCEPTIONS
              generate_subpool_dir_full = 1
              OTHERS                    = 2
          IF sy-subrc <> 0.
            MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                       WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ENDIF.
    *The structure is assigned to the table <l_table>
          ASSIGN new_table->* TO <l_table>.
    *Structure of Work Area of the table created.
          CREATE DATA new_line LIKE LINE OF <l_table>.
    *The structure of work area is assigned to <l_line>
          ASSIGN new_line->* TO <l_line>.
          MOVE wa TO <l_line>.
          ASSIGN COMPONENT wa OF STRUCTURE <l_line> TO <l_field>.
          INSERT <l_line> INTO TABLE <l_table>.
          CLEAR : <l_w_record>.
      ENDDO.
      CLOSE DATASET l_w_file .
      IF sy-subrc NE 0 .
        p_subrc = 1 .
        EXIT .
      ENDIF .
    Refere above code as per your requirement.

  • I'm Missing One Step In getting Multiple Rmx Outs to work

    so i select inst 1 with mult stylus. i click on fader and it gives me the rest of auxs. i select rmx with for now 3 different samples in multi. now how do i trigger midi 2 through 8. do i have to do something in environment? if i recall before i set main instrument midi to all but thats only playing the sample on midi channel 1.
    thanks for your help

    ok so i watched vide v and set up like before. they don't have a setup for logic 8 which has more features for example,what are the multiple output stereo for? i used stereo only. and what are the rmx auxs for. when you hit the + sign it add auxs. do you need that?
    thanks

  • Re-arrange the flat file out put in APD

    Hi Guys,
    I am loading data in APD,soruce is Query and target is Flat file.i want to re-arrange the out put file.
    Let me know what are the possible ways to re-arrange the columns in the out put flat file.
    Regards,
    Jayapal

    There are three ways to do this:
    1. Use Hide or Rename Columns (Projections) under Transformations in between the query and the flat file (recommended method)  
    Under the field selection tab..transfer the fields to the right pane in the order you wish to view thwm in.
    2.Drag and drop a routine
    Go to source fields tab
    Move the entries in the right to the bottom left 'Source Fields' pane.
    Then go to the Target field tab.
    Right Click on the row and click unfreeze columns
    Now you can drag & Drap and re-arrange the fields.
    Insert the routine in between query and Flat file
    3.  Change the order of the fields in the Query Definition( Not Recommended)
    Cheers!

  • Reg: Out put could not be issued

    Dear All,
    when i am excute VL03N to get output of smartform  i am getting message like Out put could not be issued message vl086

    Hi Reshma p,
    For that U have to assign output type...
    Check out in NACE transaction whether it has been made or not...
    In VL03N>Give a document number and enter the tcode then in, Menu>Extras>Choose Delivery Output>Header/Item(choose one), and here you have to give the output type in general.
    Have a look on similar issue with VF03
    VF03 smartform: Output could not be issued
    Hope it will solve your problem..
    Thanks & Regards
    ilesh 24x7

Maybe you are looking for

  • Header and Footer in Block ALV Display

    Hi All, My requirement includes to ALV Block List Display with header and footer. I have made two forms TOP_OF_PAGE and END_OF_PAGE . I have pass the form and name of event to an internal table it_events. This it_events[] is then passed to FM ' REUSE

  • Firefox Crash Report LOOP - can't get out and can't launch Firefox

    Hi. I'm new here. My general sysinfo is at the end of this email. I have a Firefox problem. I've actually already read all the solutions I could find so far, on another tech site, that seem to be related to my particular problem and tried them all, b

  • Sounds are not working on iPhone 3g

    I made an application that play some sound files. Everything is working correctly on simulator and iPod touch but sounds are not working on iPhone 3G. Please help...

  • Prompt not displayed in first item of loop

    Hello, I use a cursor to access some info of fields I fill with a dynamic select, in the cursor I get the field_name (for the select) and the prompt I need to show on the item. When I loop through the loop for the first time to place the prompts on t

  • JIT Schedule output getting determined even for FRC Release

    Hi, We are using LPA type scheduling agreement as we need generate releases for FRC Schedule and JIT schedule. We have copied the standard and created 2 output types: ZFRC for FCR Schedule and ZJIT for JIT Schedule. When we run ME84 to generate the r