How to store file into a directory?

i want to save the file(text file) into the directory which i have created using File object in the codes below. how do i do it?
public void saveString(String filename, String string)
          //declare textfile to be null
          PrintWriter textFile = null;
          String line = null;
          try {
               // writes to write.txt
               textFile = new PrintWriter (new FileWriter(filename,true));
               line = string;
               // save string in textfile
               textFile.println(line);
               textFile.close();
               // create a directory (to store (output).xml file)
          File fobj = new File("Testing");
          fobj.mkdir();
          catch (IOException e) {
               System.out.println("Error in opening file");
               System.exit(0);
     }

create the directory first and then create the file u want liek this
File f = new File (fobj,filename);
and then open the fiel to write like this
textFile = new PrintWriter (new FileWriter(f,true));
regards
rohan

Similar Messages

  • How to Import file into sap directory.

    Hi all,
    I need to import a .XML file into SAP-BW directory from my local pc.
    By tcod AL11 I can only display all the directories, but I cannot import/upload this file.
    How I Can create my own directory e.g /usr/sap/tmp123
    Help me please.
    thanks.
    Kaustubh.

    Hi Kaustubh,
    Use the FM ARCHIVFILE_CLIENT_TO_SERVER.
    Give Filename + path for both the source and destination and your file will get transferred to the specified directory in AL11.
    But I am not sure about creating your own directory in AL11.
    Reward if helpful.
    Regards
    Hemant Khemani

  • How to upload  and download a files into AL11 directory in ABAP

    Hi,
                   How to upload  and download a files into AL11 directory in ABAP
    thanks
    Moderator message: please search for available information/documentation.
    Edited by: Thomas Zloch on Mar 21, 2011 9:18 AM

    You should try one of these forums for an answer to your question:
    http://swforum.sun.com/jive/forum.jspa?forumID=116
    http://community.java.net/netbeans
    http://linux.java.net

  • How to store file content in database??????

    how to store file in database and retrived

    How to use Google to search for answers to questions that have been asked literally thousands of times previously??????
    How to post into the correct forum???????
    How to use less punctuation??????

  • How To Store Files On a Server?

    I am using the Tomcat 5.0.27 web container. I have always store things into the database. Now, I am told to store files (uploaded files) on the server. And, when clients want the files later on, clients can download them.
    Because I have not yet had this concept, I need help and explanation.
    1. How to store files on a server?
    2. Where on the server that files can be stored?
    3. How to let clients download files when they are asked to be viewed?

    Look at the Jakarta Commons FileUpload package.

  • How to convert files into DAT?

    Does anyone know how to convert files into DAT? Not The other way around please.

    This might do it:
    http://www.videoconverterformac.com/dat-converter-for-mac.html
    but can't imagine why you would want to!

  • How to import Photos into Active Directory

    Hi -
    IT Director asked me to import employees pictures into Active Directory so that we can use them in Outlook, SharePoint, Lync etc.
    Do you know how to import pictures into Active Directory?

    Thumbnailphoto Attribute in active directory is responsible for adding photos to Active directory.
    By Default Replication of this attribute will be disabled to Global catalog server. To make use of this facility we will have to enable replication of this attribute to Global Catalog. ( To accomplish this you will have to edit the schema using Active directory
    schema snap in).
    Refer Below link which explains about enabling the replication of Thumbnailphoto attribute to Global catalog.
    http://www.msexchange.org/articles_tutorials/exchange-server-2010/management-administration/configuring-using-display-picture-exchange-server-2010.html
    Requirements
    Minimum requirement for your exchange enviornment to use this - Exchange 2010.
    Exchange 2007 Don't support uploading photos AFAIK.
    Domain controller should be running with atleast windows server 2008 or later. And
    schema has to be windows server 2008
    Additionally for your information,
    How to remove the uploaded photos?
    Either You can edit the Thumbnailphoto attribute using ADSIedit and remove the entry which is assocaited with Thumbnailphoto attribute.
    Or,
    Try this.
    The Import-RecipientDataProperty and Export-RecipientDataProperty cmdlets allow you to import and export the photo blob to and from
    thumbnailPhoto attribute, but there's no Remove-RecipientDataProperty cmdlet to remove it. You can use the
    RemovePicture switch of Set-Mailbox cmdlet to remove a user's photo. For example:
    Set-Mailbox "Bharat Suneja" -RemovePicture
    Check out the below link which explains in and out of uploading photos,
    http://blogs.technet.com/b/exchange/archive/2010/06/01/gal-photos-frequently-asked-questions.aspx
    http://blogs.technet.com/b/ilvancri/archive/2009/11/17/upload-picture-in-outlook-2010-using-the-exchange-management-shell-exchange-2010.aspx
    To know about uploading photo using powershell ask this question in powershell forum
    http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/threads
    Regards,
    _Prashant_
    MCSA|MCITP SA|Microsoft Exchange 2003 Blog - http://prashant1987.wordpress.com Disclaimer: This posting is provided AS-IS with no warranties/guarantees and confers no rights.

  • Does anyone know how to convert file into a .png?

    Does anyone know how to convert file into a .png?
    Thanks

    I tried to give an answer with less steps. I know it's a Pages file & all you have to do is select & copy the content in your Pages file & then open Preview.app. Next time I'll include the exporting to PDF & opening that in Preview.app or in Pages go to File > Print > click on the PDF button in the lower left of the print window & choose Open in Preview.

  • How to List files in a directory into an Array

    Does anyone know of the best way to load all of the files in a specified directory into an array. (not going into sub directories either).
    I was to be able to do something like this.... (pseudo)
    String directory = "C:\";
    String [] theList;
    do
    get next file name;
    add to theList;
    }while(!End of Directory)
    Done.

        public static void main(String args[]) {
         String directory = "C:\\";
         File dir = new File(directory);
         File [] theList = dir.listFiles();
         for(File file : theList)
             if(!file.isDirectory() && !file.isFile())
              System.out.println(file.getName());
         }This will list every item in the coot of C:\ that is not a file or a directory. Change the if statement to fit your needs.
    ~Tim

  • How best store files on application server: Tables vs File system

    Hi Experts,
    We want to let users to upload files to application server. The number of files can potencially grow over time (1000 files every month) though I whould like to limit size of each file not more than 1-2 MB.
    Also files should be classified (having custom attributes) so later on we need to search, select files according to attributes.
    So what are the best options in long run (for performance, reliability etc)?
    We have NW system 7.0 with MaxDB
    I can think of the following options:
    1. Store files in TRANSPARENT table in RAWSTRING. Easiest variant (to select files etc) Here I have concerns how this table and database behave after some period of time and what will happen if size will grow to let say 50 GB. Will it work? What are normal size limits for transparent tables?
    2. Store files in CLUSTER table in RAWSTRING. Less convenient to work with (joins are not allowed etc). Will cluster table help to handle big size of table? What are practical size limits for cluster tables?
    3. Store files on file system (on application server) and write info (attributes etc) into ztable. Select from ztable and read content file from file system (dataset commands?). So files will be written to one directory just one after another.
    What are the best option to follow? I would personally prefer option 1 as easiest but have servious concerns regarding size of one transparent table.
    What do you recommend?
    Regards,
    Dmitry.
    Edited by: Dmitry Kalmykov on Jul 28, 2009 8:58 AM

    Hi,
    I too feel that option 1 would be best choice.
    For your ref: Check the Transp.table REPOSRC and the field name DATA
    Also Check the technical settings (Size category).

  • How to  store file in Application server.

    Hi all,
    I have done a report where using excel sheet data i hv to insert in ztable. I have done it i hav  converted excel sheet data into internal table and then inserted into ztable. It is working properly. using p_file like rlgraph-filename i have taken the parameter and function module filename_f4 uploaed file.
    Now i when i am runing the report it is inserting properly in foreground. But  i have requirement that i have to run the report in background but it is giving error in background. So what i do is the excel sheet which i take as input should be stored in Application server and then i have to pick up the file from application server during the background process. So any body can tell me how to write the program  to store file in application server and pickup that file again to run it in background.
    <b>useful answers will be rewarded</b>
    Regards,
    Sunil kumar.

    HI
    see this program where EXCEL to INTERNAL TABLE and then TO APPLICATION server
    REPORT  ZSD_EXCEL_INT_APP.
    parameter: file_nm type localfile.
    types : begin of it_tab1,
            f1(20),
            f2(40),
            f3(20),
           end of it_tab1.
    data : it_tab type table of ALSMEX_TABLINE with header line,
           file type rlgrap-filename.
    data : it_tab2 type it_tab1 occurs 1,
           wa_tab2 type it_tab1,
           w_message(100)  TYPE c.
    at selection-screen on value-request for file_nm.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
    *   PROGRAM_NAME        = SYST-REPID
    *   DYNPRO_NUMBER       = SYST-DYNNR
    *   FIELD_NAME          = ' '
       STATIC              = 'X'
    *   MASK                = ' '
      CHANGING
       file_name           = file_nm
    EXCEPTIONS
       MASK_TOO_LONG       = 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.
    start-of-selection.
    refresh it_tab2[].clear wa_tab2.
    file = file_nm.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        filename                      = file
        i_begin_col                   = '1'
        i_begin_row                   =  '1'
        i_end_col                     = '10'
        i_end_row                     = '35'
      tables
        intern                        = it_tab
    EXCEPTIONS
       INCONSISTENT_PARAMETERS       = 1
       UPLOAD_OLE                    = 2
       OTHERS                        = 3
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    loop at it_tab.
      case it_tab-col.
       when '002'.
        wa_tab2-f1 = it_tab-value.
       when '004'.
        wa_tab2-f2 = it_tab-value.
      when '008'.
        wa_tab2-f3 = it_tab-value.
    endcase.
    at end of row.
      append wa_tab2 to it_tab2.
    clear wa_tab2.
      endat.
    endloop.
    data : p_file TYPE  rlgrap-filename value 'TEST3.txt'.
    OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    *--- Display error messages if any.
      IF sy-subrc NE 0.
        MESSAGE e001(zsd_mes).
        EXIT.
      ELSE.
    *---Data is downloaded to the application server file path
        LOOP AT it_tab2 INTO wa_tab2.
          TRANSFER wa_tab2 TO p_file.
        ENDLOOP.
      ENDIF.
    *--Close the Application server file (Mandatory).
      CLOSE DATASET p_file.
    loop at it_tab2 into wa_tab2.
      write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.
    endloop.

  • How to store files in the cloud??

    I just signed up to photoshop CC.  How do I store files in the cloud?

    Yes, finally, thank you. 
    I must say, this whole CC thing is opaque as far as learning something specific.  The FAQ experience leads into a maze of irrelevant paths when you (rather, I) want somethin specific.  I don't even know how to actually get into this forum -- I stumbled into it te first time, and the second, and now this time -- although your answer to my first question finally led me to set up the CC folder.
    I hope things get easier from here.  Having said that, I have to admit I don't know how to sign up to Behance.  When I go there I have to sign in but I'm not given a place to Sign UP.  Sigh.  Maybe you can help me out again.
      -yoram

  • How to store pdf into blob, index it and search it?

    I am trying to store pdf into a column, index the column and search it.
    I store pdf file into blob column with either the following code or with an interface in apex
    declare
    Dest_loc BLOB;
    Src_loc BFILE := BFILENAME('DIR_TESTCASE', 'intermedia.pdf');
    BEGIN
    INSERT INTO pdffiles(id, description)
    VALUES(1, 'InterMedia Concepts')
    RETURN text INTO Dest_loc;
    DBMS_LOB.FILEOPEN(Src_loc, DBMS_LOB.LOB_READONLY);
    DBMS_LOB.LOADFROMFILE(Dest_loc, Src_loc, dbms_lob.getlength(Src_loc));
    DBMS_LOB.FILECLOSE(Src_loc);
    COMMIT;
    END;
    then i need to create an index
    begin
    ctx_ddl.create_preference('pdf
    lexer', 'BASICLEXER');
    ctx_ddl.set_attribute('pdf_lexer', 'printjoins', '_-');
    end;
    create index PDFFILES_TEXT on PDFFILES(TEXT) indextype is ctxsys.context
    parameters ('lexer pdf_lexer');
    sqlplus says index created but windows gives an error and closes ctxhx.exe
    and of cource when I tried to make a search like
    select id, description
    from pdffiles
    where contains(text,'Oracle') > 0;
    it doesn't return any results.
    My database is 10g XE, I also tried it on Oracle 10.2.0.3 EE

    It is possible to store pdf and doc files in a blob column, create a text index, and search them, and display them. However, you cannot expect to just select doc and pdf data directly from a blob column and expect to be able to read it, due to all of the special formatting characters. You need to use ctx_doc.snippet or ctx_doc.markup or some such thing to format it and make it readable. Please see the demonstration below. You can search the online documentation for complete syntax, additional information, and examples.
    SCOTT@orcl_11g> CREATE TABLE my_files
      2    (id   NUMBER,
      3       doc  BLOB)
      4  /
    Table created.
    SCOTT@orcl_11g> CREATE OR REPLACE DIRECTORY DIR_TESTCASE AS 'c:\oracle11g'
      2  /
    Directory created.
    SCOTT@orcl_11g> declare
      2    Dest_loc BLOB;
      3    Src_loc     BFILE;
      4  BEGIN
      5    INSERT INTO my_files (id, doc) VALUES (1, EMPTY_BLOB())
      6    RETURNING doc INTO Dest_loc;
      7    Src_loc := BFILENAME ('DIR_TESTCASE', 'banana.pdf');
      8    DBMS_LOB.FILEOPEN (Src_loc, DBMS_LOB.LOB_READONLY);
      9    DBMS_LOB.LOADFROMFILE (Dest_loc, Src_loc, dbms_lob.getlength (Src_loc));
    10    DBMS_LOB.FILECLOSE (Src_loc);
    11    INSERT INTO my_files (id, doc) VALUES (2, EMPTY_BLOB())
    12    RETURNING doc INTO Dest_loc;
    13    Src_loc := BFILENAME ('DIR_TESTCASE', 'test1.doc');
    14    DBMS_LOB.FILEOPEN (Src_loc, DBMS_LOB.LOB_READONLY);
    15    DBMS_LOB.LOADFROMFILE (Dest_loc, Src_loc, dbms_lob.getlength (Src_loc));
    16    DBMS_LOB.FILECLOSE (Src_loc);
    17  END;
    18  /
    PL/SQL procedure successfully completed.
    SCOTT@orcl_11g> INSERT INTO my_files (id, doc)
      2  VALUES (3, UTL_RAW.CAST_TO_RAW ('blob data for id 3'))
      3  /
    1 row created.
    SCOTT@orcl_11g> COMMIT
      2  /
    Commit complete.
    SCOTT@orcl_11g> SELECT id, DBMS_LOB.GETLENGTH (doc) FROM my_files
      2  /
            ID DBMS_LOB.GETLENGTH(DOC)
             1                  222824
             2                   19968
             3                      18
    SCOTT@orcl_11g> CREATE INDEX my_files_idx ON my_files(doc)
      2       INDEXTYPE IS CTXSYS.CONTEXT
      3  /
    Index created.
    SCOTT@orcl_11g> SELECT COUNT (*) FROM dr$my_files_idx$i
      2  /
      COUNT(*)
           308
    SCOTT@orcl_11g> COLUMN first_45 FORMAT A45
    SCOTT@orcl_11g> SELECT id,
      2           UTL_RAW.CAST_TO_VARCHAR2 (DBMS_LOB.SUBSTR (doc, 18, 1)) AS first_45
      3  FROM   my_files
      4  /
            ID FIRST_45
             1 %PDF-1.5
    %âãÏÓ
               1
             2 ÐÏࡱá
             3 blob data for id 3
    SCOTT@orcl_11g> EXEC CTX_DOC.SET_KEY_TYPE ('ROWID')
    PL/SQL procedure successfully completed.
    SCOTT@orcl_11g> COLUMN keywords_in_context FORMAT A45 WORD_WRAPPED
    SCOTT@orcl_11g> SELECT id,
      2           CTX_DOC.SNIPPET
      3             ('MY_FILES_IDX',
      4              ROWID,
      5              'contents OR (fruit of the month) OR data',
      6              '<<',
      7              '>>')
      8             AS keywords_in_context
      9  FROM   my_files
    10  WHERE  CONTAINS (doc, 'contents OR (fruit of the month) OR data') > 0
    11  /
            ID KEYWORDS_IN_CONTEXT
             1 <<Fruit of the Month>>
               Banana
               Bananas are the most popular
             2 This is the original <<contents>> of
               test1.doc.
             3 blob <<data>> for id 3
    SCOTT@orcl_11g>

  • Write to excel file (into AL11 directory)

    Hi,
    I am able to loop an internal table and write to csv file in AL11 directory.
    But how to write to excel file instead of csv file. And how to format the excel file (for example, column B should be format to numeric and column E should format to date format), and are we able to put like red color on column C for example?
    Thanks in advance.

    Hi,
    You need to add the tab inbetween all the fields of internal table and upload to application server using
    OPEN DATASET
    TRANSFER
    CLOSE DATASET.
    to add the tab inbetween the fields..you can use this code....
    concatenete itb-field1 itab-field2......... into string seperated by CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
    one exception whicle uploading data to the Application server you need to convert dec or currency field to char type otherwise it will give you short dump.

  • Help Required:How Upload Excel file Into Oracle Table Using PLSQL Procedure

    Please Help , Urgent Help Needed.
    Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
    Case's are :
    1. Excel File is On Users/ Client PC.
    2. Application is on Remote Server(Oracle Forms D2k).
    3. User Is Using Application Using Terminal Server LogIn.
    4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
    5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
    6. we are Using Oracle 8.7
    So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
    Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
    Jus help to Sort This Issue ........
    you can also write me on :
    [email protected], [email protected]

    TEXT_IO is a PL/SQL package available only in Forms (you'll want to post in the Forms forum for more information). It is not available in a stored procedure in the database (where the equivalent package is UTL_FILE).
    If the Terminal Server machine and the database machine do not have access to the file system on the client machine, no application running on either machine will have access to the file. Barring exceptional setups (like the FTP server on the client machine), your applications are not going to have more access to the client machine than the operating system does.
    If you map the client drives from the Terminal Server box, there is the potential for your Forms application to access those files. If you want the files to be accessible to a stored procedure in the database, you'll need to move the files somewhere the database can access them.
    Justin

Maybe you are looking for

  • Tables for Budget allocated and spent for a WBS element

    Dear experts, I am new to PS domain, kindly tell me the table names where I can find the Budget allocated to a WBS element and Open budget for a WBS element. Thanks & Regards, Murthy.

  • Default latest created PO Number in the screen

    Hi, I have one Z program developed for PO print. It is very much similar to standard ME9F transaction / program. In ME9F transaction, as soon as we execute a transaction. The latest created PO number will appear onthe PO document filed. The same is e

  • OSA - Performance Management

    Hello, I'm in the process of trying to configure performance appraisals in ECC 6.0 that will be used with the BSP pages in ESS/MSS eventually.  I have a couple questions below that I cannot figure out through testing and have been unable to find any

  • MII 12.1 vs. 12.0

    Just got access to 12.1.3 Build(65). Can somebody give some quick insight into the following items - i) Home -> System Management -> Transaction Manager ii) Home -> Security Services -> Credential Editor iii) Home -> SAP MII Workbench -> Meta-inf iv)

  • SIL_APTransactionFact_DiffManLoad OAD FAILS - Financials_Oracle R12

    When I frist ETL Data with DAC for Financials_Oracle R12 Fails --SIL_ARTransactionFact_DiffManLoad --SIL_APTransactionFact_DiffManLoad --SIL_GLCOGSFact_DiffManLoad See Log File ======== SILOS:SIL_APTransactionFact_DiffManLoad' has completed with erro