How to read the file from ftp server

Hi
I need to read a file from a ftp server . Iam using apache lib common-net .jar .
FTPClient ftp = new FTPClient();
ftp.connect(server);
ftp.login(username,password);
FTPFile[] files = ftp.listFiles();
for(int i=0 ;i<files.length;i++){
System.out.println(" File : "+ i + " - " + files);     
InputStream ip = ftp.retrieveFileStream(path);
I got the inputstream from the ftp server. but iam not able to read the contents of the file ....
help me plzzzzz

Hi
I have one more problem . first i try to read the file and write the file in local directory . then i try to read the data in the remote file .. iam getting the datas as null.
InputStream ip = ftp.retrieveFileStream(path);                    
File f = new File("D:\\ftp.txt");                    
FileOutputStream fo = new FileOutputStream(f);
byte[] buf = new byte[1024];
while ((len = ip.read(buf)) > 0) {                         
fo.write(buf,0,len);               
fo.close();
BufferedReader br = new BufferedReader(new InputStreamReader(ip));
String line;
do {
line = br.readLine();
System.out.println(" data " +line);
}while (line != null);

Similar Messages

  • Problem while reading the file from FTP server

    Hi Friends,
    I have a problem while fetching files from FTP server.
    I used FTP_Connect, FTP_COMMAND function modules. I can able to put the files into FTP server.
    but I cant able to pick the files from FTP server.
    anyone have faced similar issues kindly let me know.
    Thanks
    Gowrishankar

    Hi,
    try this way..
    for reading the file using FTP you need to use different unix command ..
    Prabhuda

  • How to read .xls file from FTP server t oInternal table

    Hi
    am using the FTP_SERVER_TO_R3 to read xls file from FTP server to internal table
    but the data i get in LT_TEXT is special characters.
    CALL FUNCTION 'FTP_SERVER_TO_R3'
    EXPORTING
    handle = hdl
    fname = f_name "ProdDataFromCRM.xls.
    * CHARACTER_MODE = 'X'
    * IMPORTING
    * BLOB_LENGTH =
    TABLES
    BLOB = lt_text
    * TEXT = lt_text
    EXCEPTIONS
    TCPIP_ERROR = 1
    COMMAND_ERROR = 2
    DATA_ERROR = 3
    OTHERS = 4
    can any one help me out to get the exact data..
    Really appreciate your quick response..
    Thank You

    Hi, if you really retrieve an excel file, you can not see the data in ABAP. You may see them in Excel. For this you may use
    CALL METHOD document->open_document_from_table
    of the interface i_oi_document_proxy for OLE objects. You can access the data with reference to the interface i_oi_spreadsheet.
    Please check [Desktop Office Integration (BC-CI)|http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCIOFFI/BCCIOFFI.pdf] for details.
    But, who knows, perhaps you want "And Now For Something Completely Different".
    Regards
    Clemens

  • How to read XL file from FTP server

    Hi all,
    I have a requirement like to read file from FTP server using path
    ftp:
    10.212......\DTR\DTR_ Accounted_Out
    and again save  other file in same location ,
    to doing this RFC connection is required?
    give a  procedure or program to do this requirement ..
    To create rfc for FTP which connection type can i use ?
    Give complete settings to create rfc destination

    Hi Rakhi,
    Use the below code to check if you have received the proper data.
    call function 'FTP_SERVER_TO_R3' "Get data as character instead of BLOB
        exporting
          handle         = hdl
          fname          = docid
          character_mode = 'X'
        tables
          text           = chardata.
    If the data is incorrect, it is possible that you are in the wrong directory.
    Use
    call function 'FTP_COMMAND'
        exporting
          handle        = hdl
          command       = 'cd mydir\mysubdir' "cd <space> your path
        tables
          data          = result
        exceptions
          tcpip_error   = 1
          command_error = 2
          data_error    = 3.
    Regards,
    Jovito.

  • How to read the file from a folder.

    Hi All,
    How to read the file from a folder or directory from the non sap server / remote server.
    Regards
    Sathis

    open dataset filename for input in text mode
                         encoding default.
    filename is character type variable with the destination filename.
    Edited by: Jino Augustine on Apr 19, 2010 1:31 PM

  • Regarding Reading the file from Application Server

    Hi,
    I am trying to read data from Application Server but due to special characters it is getting dumped out.
    US24,Q,Acero (Carbon),AA,0010,0001,01,Ver Mir para dimension#
    US24,Q,Acero (Carbon),AA,0010,0002,01,Area rectificada sin da#os ra
    US24,Q,Acero (Carbon),AA,0010,0003,01,Ver Mir para dimension#
    US24,Q,Acero (Carbon),CD,0010,0001,01,ITPE Soken para verificacion
    US24,Q,Acero (Carbon),CD,0010,0010,01,No se permite desprendimiento
    US24,Q,Acero (Carbon),CD,0010,0002,01,"Vernier, cinta metrica"#
    In the last line it is going into dump due to special character ".
    Please suggest.
    Thanks
    Priyanka.

    Hi,
    You can check the mode in which you are reading the file
    from application server that is
    Open Dataset in Binary or Text Mode.
    Hope it helps
    Regards
    Mansi

  • How to compare the files from one server to another

    Hi !
    I want to compare the files present in one server to another server. I had to list out the files which is not present in the server and import those files to an excel file. There are lot of folders and lot of files present inside those folders. I want a java or jsp or javascript program code for this or any site which indicates how to do. What are the requirement for this program to implement like any tool or any other techniques. Please can u help me out.

    No ... The package mentioned in
    http://www.oracle-base.com/dba/miscellaneous/ftp.pks
    this works for across the server i.e. transfer the files from one server to other (it is basically ftp) ..
    So it is NOT correct that this code transfer the file between two location & with in server..

  • Error in Reading the file from Application Server

    Hi,
    This Error is regarding one of my interface, the issue is that , the interface reads data from file in bunch suppose 100 records at a time , then processes those records and once finished go for next 100 records .
    Noe the error is that , the process takes place till 500 records correctly but when it went to fetch for next 100 i.e fom 501 to 600 it selects only 501 to 583 .
    this records has been processed successfully but the job finished there only
    but the file contains 788 records
    When the same file has been run in other server it ran successfully without such error .
    Can you please suggest how to resolve the issue

    Hi,
    Try to manually download the file from application server using standard transactions, and than check how many records are you able to download from app. server.
    I guess there might be something wrong with the format of 583rd record, which makes sap assume that the file has come to an end.
    Hope this will help you.
    Regards,
    Vinit...

  • How to transfer the files from one server to another through pl/sql...?

    I want to transfer all the files from source server with respective directory to designation server with respective directory (designation server - oracle reside server).
    Is it possible to ftp from one server to another server(designation server - oracle reside server) through pl/sql. these two servers are independent & unix server.

    No ... The package mentioned in
    http://www.oracle-base.com/dba/miscellaneous/ftp.pks
    this works for across the server i.e. transfer the files from one server to other (it is basically ftp) ..
    So it is NOT correct that this code transfer the file between two location & with in server..

  • Not recognizing # while reading the file from application server

    Hi
    I am reading a file from application server. While reading into internal table with read statement the last field in each record is filling with hash symbol in the last digit. If I write any if condition with HASH symbol its not going inside the if condition, means its not recognizing as hash may be its internally treating as some other. I need to remove the hash from that field. How I can do that.
    Thanks,
    kishore

    I faced exact situation. Yes, internally its treated as some other special character. What i did was, becuase hash symbol was always coming at the end...i created a dummy field in my internal table so that it will not interfere with my actual data. When i see the data in my internal table, the hash always falls in the last field (dummy) which i will ignore. I could not get solution to remove this hash so i adopted this approach and it worked!!
    Hope it helps,
    SKJ

  • Reading a file from ftp server

    Hi
    I am able to put file on ftp server using ftp adapter.But same settings are not working while polling file on ftp.
    Do i need to do some settings for get operation??

    Hi,
    Check the file permissions and for testing give all read/write/execute permissions to the file to be read from FTP. Also check the file modification date of the file.
    Check for the logs at 2 places for any error messages:
    - SOA server diagnostics logs
    - FTP server logs
    You can also enable the FINEST level of Adapter logs for adapters and see for the detailed errors in the diagnostic logs.
    FMW Console > right click soa-infra > Logs > Log Configuration > expand oracle.soa > set Trace32 : FINEST for oracle.soa.adapter
    Regards,
    Neeraj Sehgal

  • Pick the  file from FTP Server and place it on the App. Server of R/3

    Hi Guys,
      I had a requirement where i need to pick the file from the FTP Server and place it on the Application Server in R/3. If anybody has an Idea on acheiving this or if anybody has the piece of Code Snippet to acheive the same, Help me out.
    Regards,
    Kittu Chowdary.

    hi kittu,
    chk the demo programs RSFTP00* if they can help u

  • Read File From FTP Server

    Hi all,
    I have to read a file from FTP server, manipulate it and then create another file at the same location.
    Currently, I am able to write a file onto FTP server ..but how do I read the file?
    Any help will be greatly appreciated.
    Thanks,
    Haritha

    can i know how do u placing the file in FTP?
    ( default path specified in the FTP server, it might be Pre. server address)

  • How to send a file from FTP to external server

    My requirement is to send a file from FTP to D3(External) server.
    Now I am able to store the file in Appln server.
    I want to send the file created by the program thru FTP to D3 server.
    I know the username,Password,HostID,RFC destination details.
    How to send the file from FTP to D3.
    If u have any program,Plz send it...
    I dont want the function modules name...I want the example code ....
    Thanks in advance.

    Hi Sumi,
    You could do it so that you create a .bat or .cmd script to your server which does your ftp transfer.
    To do this you must use sm69 to create a external operating system command which you can call from FM SXPG_COMMAND_EXECUTE. To SXPG_COMMAND_EXECUTE you the file you need to transfer as a parameter.
    What happens is that your abap program passes the file to windows batch script (.bat .cmd) which will then do the transfer for you.
    Here's a sample of ftp-script for windows:
    echo open IP_ADDRESS_TO_YOUR_SERVER > c:zftp_transfer.ftp
    echo USERNAME>> c:zftp_transfer.ftp
    echo PASSWORD>> c:zftp_transfer.ftp
    echo put YOUR_FILE>> c:zftp_transfer.ftp
    echo quit>> c:zftp_transfer.ftp
    ftp -s:c:zftp_transfer.ftp
    also take a look here for more details:
    http://support.microsoft.com/?kbid=96269
    Ok, this might be a bit trivial but if your server is unix/aix etc.. Instead of using batch script you must do a shell script.
    Regards,
    Ville

  • Download file from FTP Server to Application Server

    Hi Friends,
    Using the standard SAP Program RSFTP002, I was able to download the file to my local PC. But my requirement is to download the file from FTP to application server.
    For RSFTP002, I am passing the username, password, host and in command 1 I am passing lcd :\temp, command 2 get filename. The file gets downloaded into c:\temp. If I do the same passing the app server path in command 1 as /usr/sap/tmp I get an error that pass cannot be found.
    Anyone please help me how to donload the file from ftp to app server.
    Thanks,
    Deepthi

    If I remember correctly the activation type on the technical settings tab must be set to "start on application server" in transaction SM59 for the RFC destination for the FTP server.  This should allow the files to be transferred to/from the application server.
    Regards,
    Steve.

Maybe you are looking for

  • Gnome killed after power outage

    While using Gnome, the power to my apartment blinked out. I don't have a UPS, so this caused my computer to shut down. Upon restarting, all of Gnome's default icons were replaced with the little paper, all of my Applications menu was gone, and only a

  • Create MM ERS Invoice based on Head Office-MRRL

    Hello MM Experts, There will be multiple vendors who supply materials.  However, the Invoice should be created only on the Head Office Vendor. This is standard functionality. Supply vendor 1 - Head Office - X Supply vendor 2 - Head Office - X While c

  • Local apps crash when logged in as Xserve user - HELP!

    I run a new elementary school mac lab: 24 eMacs (OS 10.4.2) as managed users/groups with remote home directories on an Xserve. We run the programs locally and save to the server. Many of our apps are crashing leaving the OS fine. These are new OSX ed

  • Correlation ID Result from Log file

    Area : SharePoint Foundation Category : Monitoring Level : High EventID : b4ly Message : Leaving Monitored Scope (PostResolveRequestCacheHandler). Execution Time=6.92841879464484 Area : SharePoint Foundation Category : Monitoring Level : High EventID

  • WD Free-Fall Sensor in MBP

    I'm considering putting the 320GB WD Scorpio Black 2.5", SATA II, 7200 rpm, 16 MB cache WD3200BJKT into a friend's current model MBP 15,4". A while ago I read somewhere that the drive's built-in free-fall sensor conflicts with the one in the MBP itse