How to handle ASCII file in file download

Hi:
I have an applet that will download mutiple files to client's PC at the background. It handle binary files (e.g. word, excel) OK.
However, for ASCII file, it lost the line feeds, etc. so my multiple-lines file become 1 line (seems to be transfer via binary mode). Anyway to fix this ?
The relevant code segment looks like this:
public class Filedownload extends JApplet
public Filedownload()
String FileName1="template2.doc";
String webFile1 =
"http://hkzux05/~doracle/dev/"+FileName1;
String outfile1 =
"c://dev//mail-merge//" +FileName1;  
String FileName2="data1.csv";
String webFile2 =
"http://hkzux05/~doracle/dev/"+FileName2;
String outfile2 =
"c://dev//mail-merge//" +FileName2;   
try {
System.out.print("Start downloading file "+FileName1+"\n");
URL url = new URL(webFile1);
InputStream in = url.openStream();
byte[] buf = new byte[1024];
int len;
OutputStream out = new FileOutputStream(outfile1);
while ((len = in.read(buf)) != -1) {
//write byte to file
out.write(buf, 0, len);
//close the stream
in.close();
System.out.print("End downloading file "+FileName1+"\n");
System.out.print("Start downloading file "+FileName2+"\n");
url = new URL(webFile2);
in = url.openStream();
OutputStream out2 = new FileOutputStream(outfile2);
while ((len = in.read(buf)) != -1) {
//write byte to file
out2.write(buf, 0, len);
in.close();
System.out.print("End downloading file "+FileName2+"\n");
System.out.print("... Done ...\n");
catch (MalformedURLException e){
//TODO
catch (IOException e){
//TODO:FileNotFoundException caught here
finally{
//TODO
Thks

Can anyone help ?
Thks

Similar Messages

  • How to handle empty file using sftp adapter

    Hi,
    Please explain me how to handle empty files in sftp adapter.
    Thanks,
    Enivass

    Hi Enivaas,
                        I don't have the seeburger sftp adapter at hand at the moment, but asfar as I remember, this does not specifically have an empty-file handling option like the standard ftp adapter.
    So to stop emtyp files from being written, guess would need to handle this at the mapping level. For example, check for target creation criteria in the header node in mapping. If the creation criteria is not met, you can throw an error in mapping.
    You may also incorporate this condition in your Receiver determination. In this case, if the condition is not satisfied, no receiver is determined in PI.
    Regards

  • How to Handle Empty Files

    Hi Experts,
    I am doing File to File Scenario.
    If my Sender systems file is Empty , that means there is no Records in the File .
    How to Handle Empty Files ??????????
    I want to know For both Sender and As wel as Receiver Adapters
    Please Let me know..
    Regards
    Khanna

    See if u are having a sender file adapter and the file is empty u can tell the if it has to 'Process the empty file' or 'Skip the empty file processing'.
    Similarly if you have a message to going to your Receiver file adapter and the message is empty then you can decide still if you want to create a 'File with empty records' or skip creating the same.
    Regards,

  • How to handle flat file dissembler in biz-talk from getting spited in to multiple files???

    Hi,
    How to handle flat file dissembler in biz-talk from getting spited into multiple files according to number of transaction sets???
    where the Map flow is from Flat file to X12 Standard files.
    Please advise...

    You can go through following links:
    Developing
    Custom Pipeline Components
    How
    to Develop BizTalk Custom Pipeline Components - Part1
    Custom
    BizTalk Pipeline Disassembler Component
    Creating
    a custom BizTalk 2010 pipeline component–Part I
    add one more which talks about extending the FFDASM @http://msdn.microsoft.com/en-us/library/ee267856(v=bts.10).aspx
    Regards,
    Rachit
    Vote, if you find it useful.

  • How to handle additional files.

    Hi,
    In PI we can pick up additional files in the Sender File Adapter.
    My scenario would require to pick up invoice1.txt and and invoice1.jpg (the .jpg is the additional file)
    I need to get FCC for .txt file, map it,  and send it out to R3 with a proxy.
    The additional file should go to a share (also on the R3, and then be accessible via a link)
    Is this possible?
    What configuration is needed to separate the .txt from the .jpg? Would it require BPM?
    Any useful pointers/documents on the subject would be appreciated
    kr
    Robert

    Hi,
    I know how to configure the sender file adapter to pick up the additional file.
    What i am looking for is how to handle it inside the integration engine, because i need to split the message from the additional file.
    As mentioned above i need to send the .txt file via proxy to R3 and the .jpg file as is to R3, but it needs to go a share on the R3 directory.
    file.txt + file.jpg  -->  Sender File Adapter --> PI   / -->  Proxy  --> records form the file.txt
                                                                                 \ -->  Receiver File Adapter --> .jpg
    Thx
    Robert

  • How to handle Big FIles in SAP PI Sender file adapter

    Hi all ,
    I have developed a interface , where it is File to Proxy, it is fine when i do with small and normal files
    The structure contain one  Header unbounded  detail and one  Trailer, how to handle when the file size is more than 40 MB
    Thanking you
    Sridhar

    Hi Sridhar Gautham,
    We can set a limit on the request body message length that can be accepted by the HTTP Provider Service on the Java dispatcher. The system controls this limit by inspecting the Content-Length header of the request or monitoring the chunked request body (in case chunked encoding is applied to the message). If the value of the Content-Length header exceeds the maximum request body length, then the HTTP Provider Service will reject the request with a 413 u201CRequest Entity Too Largeu201D error response. You can limit the length of the request body using the tting MaxRequestContentLength property of the HTTP Provider Service running on the Java dispatcher. By default, the maximum permitted value is 131072 KB (or 128MB).You can configure the MaxRequestContentLength property using the Visual Administrator tool. Proceed as follows:
           1.      Go to the Properties tab of the HTTP Provider Service running on the dispatcher.
           2.      Choose MaxRequestContentLength property and enter a value in the Value field. The length is specified in KB.
           3.      Choose Update to add it to the list of properties.
           4.      To apply these changes, choose  (Save Properties).
    The value of the parameter MaxRequestContentLength has to be set to a high value.
    The Visual administartor tool may be accessed using this link
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/40a08db9-59b6-2c10-5e8f-a4b2a9aaa3d2?quicklink=index&overridelayout=true
    In short  ICM parameters to reset values for this case are
    icm/HTTP/max_request_size_KB
    icm/server_port_ TIMEOUT
    rdisp/max_wprun_time
    zttp/max_memreq_MB
    Please look into this thread to know more about ICM parameters
    http://help.sap.com/saphelp_nw04/helpdata/en/61/f5183a3bef2669e10000000a114084/frameset.htm
    Second solution is that you must split the source file, so that each file is less than 5MB in size, then PI would not cause problem for file size between 1MB-5MB. you can insert header and trailer for individual smaller file obtained after split. All this can be done using scripts or conventional programing provided individual records within file are independent of each other. Finally you have to rename each new file created and put them in PI folder in sequential manner. All this can be achieved by simple shell script/batch file, a C code or java code. If you are going for a C or Java code you need a script to call them from PI communication channel parameter  "run operating system command before message processing".
    regards
    Anupam

  • In unicode programs how to handle unix files

    Hi Abapers,
    In Unicode programs.
      while transfering  file from unix directory to pdf format, logo is missing in that pdf file .
    how to handle this error.
    Thanks,
    Praveen

    have a look
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/60a35b0b-de0a-2a10-4ea5-dd82e6bbd74d
    Regards
    Shashi

  • Time Machine - how it handles 'temporary' files

    I'm wondering how Time Machine handles 'temporary' files. By 'temporary' I mean the following. Supposing that I want to make some legitimate copies of some DVDs that I have made. I load up DVD1 and make a copy. I load up DVD2 and make a copy. I then delete DVD1 and DVD2 from my iMac as being no longer required. Now suppose Time Machine backed up before I did the delete. I think that I am right in saying that Time Machine will faithfully backup DVD1 and DVD2. After all, that is what it is supposed to do. But when I delete DVD1 and DVD2 from my iMac, Time Machine will not delete DVD1 and DVD2 from its' backup archive (again, because that is what it is supposed to do).
    So if I continue to make copies of DVDs..say 50 different ones...then that means that, my Time Machine backup will fill up with 50 x 4.7Gb (ie over 200Gb) of stuff that I don't want.
    Please understand that I don't have an issue with TM. Just want to understand the underlying mechanics a bit more. If my premise is correct then I guess the easiest option is to temporarily inhibit TM from doing its' backup while I am going through the load/copy/delete process. Only must remember to turn TM back on afterwards.
    Thanks

    Roger Sinden wrote:
    I'm wondering how Time Machine handles 'temporary' files. By 'temporary' I mean the following. Supposing that I want to make some legitimate copies of some DVDs that I have made. I load up DVD1 and make a copy. I load up DVD2 and make a copy. I then delete DVD1 and DVD2 from my iMac as being no longer required. Now suppose Time Machine backed up before I did the delete. I think that I am right in saying that Time Machine will faithfully backup DVD1 and DVD2. After all, that is what it is supposed to do. But when I delete DVD1 and DVD2 from my iMac, Time Machine will not delete DVD1 and DVD2 from its' backup archive (again, because that is what it is supposed to do).
    So if I continue to make copies of DVDs..say 50 different ones...then that means that, my Time Machine backup will fill up with 50 x 4.7Gb (ie over 200Gb) of stuff that I don't want.
    no, this will not be this bad. TM constantly thins its backups. it keeps hourly backups for 24 hours and then deletes all but one of them. it keeps daily backups for 30 days and then deletes all but one for every week.
    so if you had copies of some DVDs on your drive for a very short time they will likely be gone from TM backups by tomorrow.
    if you still think some might be kept too long exclude the folder where you create them from TM backups. that's done by adding it to the TM exclusion list in TM system preferences->options.
    Please understand that I don't have an issue with TM. Just want to understand the underlying mechanics a bit more. If my premise is correct then I guess the easiest option is to temporarily inhibit TM from doing its' backup while I am going through the load/copy/delete process. Only must remember to turn TM back on afterwards.
    Thanks

  • How to open .zip files downloaded

    I've downloaded a number of zip files using Firefox Mobile, first clicking on the "Open" button after clicking on the link to the zip file (it didn't work) , and clicking "Save" and after downloading trying to click "Open" (it didn't work either).
    How do I open zip files downloaded with Firefox for Mobile? And where are they stored when saved?
    == Extensions installed: ==
    Weave Sync

    hi i m salim dhannani from india and i want to contack with you so plz contack with me , and i want shoes buckles if you have tahn plz send me

  • Regarding ssis - how to handle new files in for each file enumerator

    Hi,
    I have one folder with 5 file text files by using for each file enumerator we store the files in to one folder but suddenly tomorrow one file add to that folder how to
    store the file into same destination?

    Inside foreach loop add a script task to check if file exists in destination folder. if exists set a boolean flag variable to True. Then link it to file system task you've using a conditional precedence constraint (Expression And Constraint). Set constraint
    as OnSuccess and expression as below
    @FlagVariable == False
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • How XI handle multiple files ?

    Hi All ,
    I am an abaper i don't know about XI much . I have one requirement. There is one XI sharepoint directory in that legacy people will place about 20 files ( based on plant wise ). Now what i want XI to do is  read each file from that directory and update the infocube in BW (i have one interface that will update the infocube) .
    No.of files are not constant .
    I have one more question How many records per file can XI Pick at a time .
    Thanks in advance . Pls help me.
    regards
    prithvi.

    Hi Prithvi,
    Since your new to XI, I will probably explain a simple Scenario and you can build on the same....
    Please go thru the following links and get an idea as to how to start off....
    Communication channel:
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/65/b11c409ce22402e10000000a1550b0/frameset.htm">Assigning Communication Channels</a>
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/2b/d5653fd1d3b81ae10000000a114084/content.htm">Communication Channel</a>
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/e3/94007075cae04f930cc4c034e411e1/content.htm">Configuring the Sender File/FTP Adapter</a>
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm">Configuring the Receiver File/FTP Adapter</a>
    Receiver agreement:
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/56/02e63f48e58f15e10000000a155106/frameset.htm">Receiver Agreement</a>
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/c1/5194426b44c56ae10000000a155106/frameset.htm">Creating a Receiver Agreement</a>
    Sender agreement:
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/db/73e03fc2269615e10000000a155106/frameset.htm">Sender Agreement</a>
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/22/522041cfb7f423e10000000a155106/frameset.htm">Creating a Sender Agreement</a>
    For detailed info, I would suggest that you go through these weblogs:
    <a href="/people/venkat.donela/blog/2005/03/02/introduction-to-simplefile-xi-filescenario-and-complete-walk-through-for-starterspart1">Introduction to simple(File-XI-File)scenario for Starters</a>
    [url=/people/venkat.donela/blog/2005/03/03/introduction-to-simple-file-xi-filescenario-and-complete-walk-through-for-starterspart2]Introduction to simple (File-XI-File)scenario for starters part2[/url]
    Regards,
    Abhy

  • Urgent!!how to open the file download dialog box????

    Hi all,
    i'm using the browse button for the user to select the file
    and a submit button, which when cliked should open the file
    download dialog box asking for open or save.
    i searched for so many forums and websites and didn't get the
    solution yet.
    i'm using jsp.
    anyone have the jsp code for the same????
    will b more helpful if u send it to me.
    thanx in advance.

    Hi
    Use the Filedialog class.
    Let your button call a method wich contains the following Java code:
    FileDialog filedialog =
    new FileDialog( Frame1.this, "Open a File", FileDialog.LOAD );
    //witch calls this constructor: public FileDialog(Frame parent, String title, int mode)
    //use Filedialog.SAVE to save a file.
    filedialog.show();
    String filename = filedialog.getFile();//to display the name of the file
    String directoryname = filedialog.getDirectory();// to display the directory name

  • How to recover a file downloaded but not saved in firefox.(when downloading gave the open option instead of save)

    Version: Firefox4Beta
    OS: Windows7
    Problem:
    I was downloading a large RAR file from the internet.
    While downloading the file i didn't selected the save option instead i gave open with(winrar) option. I have some other rar files to combine with this file. So after the completion of this partial downloaded rar file is not saved in my system.How can i recover it.
    Thanks n regards,
    Ponnukumar.S

    hi,
    Thanks for ur reply.
    But i already searched the windows and looked for that file.. But its not anywhere to be found. See first while downloading i gave the open option instead of save. So after the completion of the download the file opened automatically in winRAR. I tried to extract that file then it gave me some error. After that i closed the winrar and searched for that file in windows with search option but its not seen anywhere.
    Thanks n regards,
    S.Ponnukumar

  • How to handle flat file with variable delimiters in the file sender adapter

    Hi friends,
    I have some flat files in the ftp server and hope to poll them into XI, but before processing in XI, I hope to do some content conversion in the file sender adapter, according to the general solution, I just need to specify the field names, field seperator, end seperator, etc. But the questions is:
    The fileds in the test data may have different amount of delimiters (,), for example:
    ORD01,,,Z4XS,6100001746,,,,,2,1
    OBJ01,,,,,,,,,,4,3     
    Some fileds only have 1 ',' as the delimiter, but some of them have multiple ','.
    How can I handle it in the content conversion?
    Regards,
    Bean

    Hi Bing,
    Plz do refer the following blogs u will get an idea:
    File content conversion Blogs
    /people/venkat.donela/blog/2005/03/02/introduction-to-simplefile-xi-filescenario-and-complete-walk-through-for-starterspart1
    /people/venkat.donela/blog/2005/03/03/introduction-to-simple-file-xi-filescenario-and-complete-walk-through-for-starterspart2
    /people/arpit.seth/blog/2005/06/02/file-receiver-with-content-conversion
    /people/anish.abraham2/blog/2005/06/08/content-conversion-patternrandom-content-in-input-file
    /people/shabarish.vijayakumar/blog/2005/08/17/nab-the-tab-file-adapter
    /people/venkat.donela/blog/2005/03/02/introduction-to-simplefile-xi-filescenario-and-complete-walk-through-for-starterspart1
    /people/venkat.donela/blog/2005/03/03/introduction-to-simple-file-xi-filescenario-and-complete-walk-through-for-starterspart2
    /people/venkat.donela/blog/2005/06/08/how-to-send-a-flat-file-with-various-field-lengths-and-variable-substructures-to-xi-30
    /people/anish.abraham2/blog/2005/06/08/content-conversion-patternrandom-content-in-input-file
    /people/shabarish.vijayakumar/blog/2005/08/17/nab-the-tab-file-adapter
    /people/jeyakumar.muthu2/blog/2005/11/29/file-content-conversion-for-unequal-number-of-columns
    /people/shabarish.vijayakumar/blog/2006/02/27/content-conversion-the-key-field-problem
    /people/michal.krawczyk2/blog/2004/12/15/how-to-send-a-flat-file-with-fixed-lengths-to-xi-30-using-a-central-file-adapter
    /people/arpit.seth/blog/2005/06/02/file-receiver-with-content-conversion
    http://help.sap.com/saphelp_nw04/helpdata/en/d2/bab440c97f3716e10000000a155106/content.htm
    Regards,
    Vinod.

  • How to handle archive files

    the archive files grows to more than 80G in half a month in the PI product host.
    Is it normal?
    how can I handle it?

    Hi Shen,
        Make sure you do not have the trace/ logging option set up in your production system (Go to SXMB_ADM transaction RUNTIME- LOGGING parameter.
    It should be having a value corresponding to no logging.
    Check the other Performance tuning requierements here:
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/70ada5ef-0201-0010-1f8b-c935e444b0ad?overridelayout=true
    And if required, archive your XI messages as per this guide:
    https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/402fae48-0601-0010-3088-85c46a236f50?overridelayout=true
    Regards,
    Ravi

Maybe you are looking for