Getting the file name before downloading the data

Hello,
i got following to downloading a file from the net,
is there is a way to find out the file name of the downloading file if the url is eg; www.somewhere.com/?file=33
OutputStream out = null;
          URLConnection conn = null;
          InputStream  in = null;
          try {
               URL url = new URL(address);
               out = new BufferedOutputStream(
                    new FileOutputStream(localFileName));
               conn = url.openConnection();
               in = conn.getInputStream();
               byte[] buffer = new byte[1024];
               int numRead;
               long numWritten = 0;
               while ((numRead = in.read(buffer)) != -1) {
                    out.write(buffer, 0, numRead);
                    numWritten += numRead;
               }

Check the response headers. You can use [URLConnection#getHeaderField()|http://java.sun.com/javase/6/docs/api/java/net/URLConnection.html#getHeaderField(java.lang.String)] for this. It may be available in the [content-disposition|http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1] header.

Similar Messages

  • XML..: Problem getting the data in the XML-file..

    I'm developing a flash-file for my customer to use when
    displaying list of products he's selling.
    His list of products is inside a XML-file and he want me to
    display an overview of the products inside a datagrid, so when you
    click on the product you're interested in the productinfo will be
    displayed.
    But.. I'm having problems grabbing the data I want as it
    seems to me that I have to use the unik ID's for each products to
    get the data I want. I've tried adding the unik ID-code to my
    action script but it still won't work.
    Here's a part of the XML-code:
    <Tooldata>
    <Store name="N/A" zipcode="0033450" city="N/A" url="N/A"
    phone="N/A" fax="N/A" email="N/A">
    <Tool unikID="5_0022" control="14" cmnd="update">
    <Toolgroupe>Hammer</Toolgroupe>
    <Brand>Knipps</Brand>
    <Model>K55_Knipps</Model>
    <Price>35€</Price>
    <Weight>N/A</Weight>
    <Soldout>0</Soldout>
    <Color>Red/Black</Color>
    <Images>
    <Images image="5_0022.jpg" prioritet="1" gen_id="16"
    desc="MainImage"/>
    <Images image="5_0022_1.jpg" prioritet="2" gen_id="16"
    desc="Image 1"/>
    <Images image="5_0022_2.jpg" prioritet="3" gen_id="16"
    desc="Image 2"/>
    <Images image="5_0022_3.jpg" prioritet="4" gen_id="16"
    desc="Image 3"/>
    </Images>
    Now, the code above is only one item/product. But there are
    several proucts listed in the XML-file and I find it hard to get
    the product and the product info that I want to be displayed.
    Here's my action script:
    var xmlLoader:URLLoader = new URLLoader();
    var xmlData:XML = new XML();
    xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
    xmlLoader.load(new URLRequest("ToolData.xml"));
    function LoadXML(e:Event):void {
    xmlData = new XML(e.target.data);
    ParseBildata(xmlData);
    function ParseTooldata(TooldataInput:XML):void {
    trace("XML Output");
    trace("------------------------");
    trace(TooldataInput.Store);
    If I want to trace the images I just write
    "trace(TooldataInput.Store.Images);
    But if I want to trace one unik tool it's impossible. Well,
    maybe not impossible.. I just don't know how to do just that.
    When you trace (TooldataInput.Store); you get all the tools
    at that store. But how do I trace only one tool using the unikID??
    Thanks a lot in advance!

    Ace,
    When using E4X if you have multiple nodes at the same level
    you should be able to access them as an XMLList. Looking at your
    XML you should be able to access each <Tool> node as:
    TooldataInput.Store.Tool[0];
    TooldataInput.Store.Tool[1];
    or as an entire list
    TooldataInput.Store.children()
    WL

  • When copying one of my old cassettes to a CD how do I get the data - album name, artist, etc. to show up when the CD is inserted into a player?

    When copying one of my old cassettes to a CD how do I get the data - album name, artist, etc. to show up when the CD is inserted into a player?

    To what format file are you saving from Audacity?  Although technically AIFF format can save data tags within the file itself I have not found this to always work with all applications.  Likely the information you enter into Audacity is just being saved in the file name.  When you add this file to iTunes, if iTunes cannot find tags it recognizes it will simply add the track with the file name as the track name.  You need to add the tracks to iTunes, then enter the information using File > Get Info for a track or series of tracks,
    Some of the above information may vary slightly depending upon the file format being used.
    It helps when asking questions here to provide as much information at the onset as possible.  We didn't know until this stage that all these menus were in fact part of Audacity and not iTunes.

  • Need how to get the data from the external file in eCatt

    Hi ,
      Could any body suggest how to get the values from the external file(Excel,CSV file,Text file) and pass it as varaiable in ecatt Test script.
    Problem: Need to execute FK01-Vendor creation Transaction with multiple set of data .As per my understanding we could achive through Variants in Testdata set in eCatt .
    But is there any way to store the data in excell file and get the data and pass it to FK01 Test scripts
    Appreciate response on this

    Hi
    See the links they may be useful
    check these link,
    eCATT- An Introduction
    /people/sumeet.kaul/blog/2005/07/26/ecatt-an-introduction
    Creating Test Scripts
    /people/sumeet.kaul/blog/2005/08/10/ecatt-creating-test-scripts
    eCATT Logs
    /people/sapna.modi/blog/2006/04/18/ecatt-logs-part-vi
    eCATT Scripts Creation – TCD Mode
    /people/sapna.modi/blog/2006/04/10/ecatt-scripts-creation-150-tcd-mode-part-ii
    Creation of Test Data Container
    /people/sumeet.kaul/blog/2005/08/24/ecatt-creation-of-test-data-container
    eCATT Scripts Creation - SAPGUI Mode
    /people/sapna.modi/blog/2006/04/10/ecatt-scripts-creation--sapgui-mode-part-iii
    Integrating ECATT & MERCURY QTP Part -1
    /people/community.user/blog/2007/01/02/integrating-ecatt-mercury-qtp-part-1
    Using eCatt to Test Web Dynpro ABAP
    /people/thomas.jung/blog/2006/03/21/using-ecatt-to-test-web-dynpro-abap
    and
    -command reference
    http://help.sap.com/saphelp_nw04/helpdata/en/c6/3c333b40389c46e10000000a114084/content.htm
    /people/sapna.modi/blog/2006/04/10/ecatt--an-introduction-part-i
    http://prasadbabu.blogspot.com
    https://www.sdn.sap.com/sdn/developerareas/was.sdn?page=test_tool_integration_for_sap_e-catt.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/1b/e81c3b84e65e7be10000000a11402f/frameset.htm
    http://www.erpgenie.com/ecatt/index.htm
    hope this helps.
    Reward points for useful Answers
    Regards
    Anji

  • I have a Mac Pro OS 10.7.5 and have a DVD+R disc with files on it, but it ejects the disk after about 10 seconds--what to do?  How can I get the data off this disc?  I can see it has been already burned, so files are on there?

    I have a Mac Pro OS 10.7.5 and have a DVD+R disc with files on it, but it ejects the disk after about 10 seconds--what to do?  How can I get the data off this disc?  I can see it has been already burned, so files are on there?

    Try cleaning the lens and see if that will restore functionality to the DVD drive.  Use a DVD lens cleaning disk, if you have a can of compressed air, shoot some into the slot or wrap a fine microfiber cloth (eyeglasses cleaning cloth)  around a business card and insert it gently inside the slot.
    If no success, make an appointment at an Apple store genius bar and get a free diagnosis from them.
    Ciao.

  • How do I get the date of a file in an FTP?

    As stated in the subject.
    I am at wits end trying to get the date of a file from FTP(Stuck for days).
    I tried the "URLConnection" Class but could only get me the size of the file with "getContentLength()"
    "getContentDate()" & "getLastModified()" both give me a 0. They only works for files on HTTP but not FTP.
    Anyone has any simple solution on how to get the date of a file on FTP?
    Thanks in Advance.

    The FTP specification has long awaited the magical file meta-data access protocol, which never came. There is no FTP defined manner to obtain the date of a file. The common work-around is to get the containing directory list and <shudder> parse the format of the returned text for the target file and date. Since there is no standard directory listing format, there is no guarantee that you will be able to get that date, and your application would have to cry to the user for help.
    Some FTP applications, in addition to providing parsers for Unix/Linux and DOS/Windows directory list formats, also provide the user with a format definition script to parse whatever the user encounters.
    I hope you find this of some help.

  • Data Integrator has no read permissions to get the data file using FTP

    Hi,
    I wonder if you could help.
    We have installed the data integrator and are using FTP to get the data file from the SAP server to the DI server. The files are created by the SAP admin user with permissions 660. The FTP user is not in the sapsys group so cannot read the files.
    Has anyone come accross this problem and how did you solve it?
    Many thanks.

    Hi,
    you might want to put you entry into the EIM forum where also the Data Integrator topics are being handled:
    Data Services and Data Quality
    Ingo

  • What is the easiest way to get the data from the mailmerge to form Pages files that can be saved separately?

    Using Iwork 09 I have spent several hours setting up a mail merge from a spread sheet in Numbers to create receipts for my customers from a Pages template.
    After the merge I am left with one long Pages document that will not save as separate files; one per customer, it will only save the whole document of several receipts.
    What is the easiest way to get the data from the mailmerge to form Pages files that can be saved separately?
    Many thanks in advance.
    Richard

    Mr. Clark,
    You will probably be more pleased with the iWork apps when you begin to learn your way around. Until you learn such basic things as how to print only one page of a document, you will probably continue to be disappointed.
    Does your Print dialog look like this:
    Or like this:
    If it looks like the first one, then you will want to click this expander control:
    Regards,
    Jerry

  • When I look up the creation date for files on my Macbook I get the date and month in brackets, but not the year.  Why is this and how can I look up the year?

    When I look up the creation date for files on my Macbook (using "get info", or the information window in Iphoto) I get the date and month in brackets, but not the year.  Why is this and how can I look up the year? 

    Does the Date Modified column in a window set to List view show the date correctly, or does it also display it incorrectly?
    To add additional columns to a Finder (folder) window, with that window open and active open the View Options for it. You can do that by pressing Command-J or by selecting View Options from the View menu in the main menubar.

  • Get the data from a dbase file - .dbf.

    Hello all - good morning working on Sunday :(. I am needing to get the data from old application which run the dbase program. Need to automatique the data getting. If you have any idea, please tell to me. Thanks to you, Nóra.

    >
    Hello all - good morning working on Sunday :(. I'm not even working - how sad is that :)
    I am needing to get the data from old application
    which run the dbase program. Need to automatique the data getting. If you have any idea, please
    tell to me. Take a look here http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:711825134415.
    It worked for me, with a bit of difficulty - mostly due to my own stupidity... if you have
    any problems, post back.
    HTH,
    Paul...
    Thanks to you, Nóra.

  • Define a join in Webi Report which gets the data from two Excel files

    Hello,
    I have the following excel records as a source for my Webi Report:
    Excel 1
    Excel 2
    Date
    Month
    Month
    Year
    Year
    Total Number of Days
      in Month
    No. Of Exec
    Functional
      Area
    Now I need to show No. of executions/Total Number of Days in Month per functional area (Where Month of Excel 1 is Month of Excel 2).
    For this:
    I have Merged, Month of Excel 1 and Month of Excel 2,     Year of Excel 1 and Year of Excel 2.
    Created a variable vNoofExec , No. of Exec/Total Number of Days in Month.
    Created a graph, with Merged Month, Merged Year, vNoofExec with Region Color on 'Functional Area'.
    But, it doesn't work.
    If I replace vNoofExec with No. Of Exec I get the data, but not with vNoofExec.
    Any Idea how we can get a solution for this?
    Best regards,
    Praveen.

    Hi Amit,
    Thank you for your reply.
    I tried putting them in a table to see if I am getting the value for vNoofExec but, no, I am not getting. Here is the dummy data for both the excels:
    1. Excel 1:
    Year
    Month
    Week
    Date
    No. Of Exec
    Functional Area
    2013
    1
    30
    26
    1
    FA1
    2013
    2
    21
    20
    12
    FA2
    2013
    3
    21
    21
    1
    FA3
    2013
    4
    21
    22
    5
    FA4
    2013
    5
    21
    23
    2
    FA5
    2. Excel 2:
    Year
    Month
    TotalDays
    2013
    1
    31
    2013
    2
    28
    2013
    3
    31
    2013
    4
    30
    2013
    5
    31
    What I found is, if I create a measure like, [No. of Exec] where ([Functional Area]="FA1") and use this measure in the graph I am able to see the data even if I use Total Days in the Graph, but, I cannot create multiple measures like this because for me number of Functional Areas will be changing always.

  • How to get the data in servlet if the request encryption type is multipart/

    I am uploading files to the server.
    at that time,before upload ,I need to validate the upload file names.
    so,i am trying to get the value of those files names using
    request.getParameter("jobsheet"); in servlet.
    its giving null insted of file path.
    how to retrieve the the values of parameters if the request is multipart/form-data.
    any help please...

    I think that package works in struts framework right?
    If wrong ,correct me.
    actually I am following MVC pattern.not using struts.
    If this works even in normal web application also.then ok.
    But,Just I am looking how to get the values of jsp parameters
    I have 5 elements in jsp .
    below code:
    <form name="FileUpload" action="./UploadServlet" method="post" enctype="multipart/form-data">
    country <input type="text" name="country" value="">
    year <input type="text" name="year" value="">
    month <input type="text" name="month" value="">
    File<input type="file" name="file1" value="">
    <input type="submit">
    </form>
    I am trying to get the data in servlet like
    String country=req.getParameter("country");
    its getting null.
    I don't know how to get the values if the enctype is "enctype="multipart/form-data"
    If any one knows ,Please suggest me.

  • How can I rollback from Yosemite to Lion? I need to do this as I purchased a newer iMac and I have the old 17" iMac HD that I want to get the data migrated from. When I start the Migration Assistant it tells me that the OS X version is too old. Help!

    I have purchased a newer mid 2011 iMac for my wife to replace her dead 17"iMac from 2006. It was running Snow Leopard. The new iMac has Yosemite and when I go into Migration Assistant it tells me that the OS X is too old, implying that I cannot get the data from it. How can I migrate this data to the new iMac? I have the hard drive removed and in an external enclosure connected to the new iMac.
    Thanks,
    Bill Stratman

    Since any OS since Lion does not support Rosetta or PPC applications, you may want to check her apps for compatibility.
    Have you tried to follow all the instructions here:
    OS X Yosemite: Transfer your info from a computer or storage device
    Also, as a general note: when you got the 2011 iMac did it have the original OS installed as required by the SLA? The seller is to remove any OS version obtained at the app store since the license is not transferable - did he do that? If not, as the OS download is tied to the Apple ID used to obtain it, you will not be able to update apps or reinstall the OS, so may I suggest you do this step now before you start porting over all the files. Use Internet Recovery: Hold Command + Option + R while restarting/rebooting until you see a spinning globe and a progress bar. After 2 - 10 minutes, you'll be connected to Apple's servers and see a Utilities window. Go to Disk Utility and choose erase your drive; once finished, go back to the window and choose to reinstall OS X. This should install a fresh original OS version which you can then update and tie to your wife's Apple ID.

  • To Split a variable to get the date.

    Hi all,
        I have a variable 'file1'.This variable stores the names of the pdf files located in SAP directory.
    The name of the file is like:'PDFST0000098357US81042008',
    which containg order no ,sales org, month and date of that file creation.
    Now i have a requirement to extract that  month and year from this variable.
    Also some filenames have different format like'PDFIPF......' instead of 'PDFST.....'.
    so kindly suggest how to extract month and year from this variable.
    Thank You.

    Hi,
    You can use fm STRING_REVERSE to reverse the name of the filename. Then go ahead and extact eight letters of the reversed string and once again reverse that, so at this you will get the date part in DDMMYYYY.
    Again you can manipulate this date string to get back the original date.
    1.  use string_reverse input filename, output reversed string.
    2.  reversedstring+0(8) will extract date part ( reverse ).
    3.  Again reverse this string.
    But seeing at the example, this would be tougher if the date in the filename is not in DDMMYYYY, meaning that if the date is 1st april 2008 then if the date format is DMYYYY(142008), then the logic would go for a toss.
    Thanks and regards,
    S. Chandramouli.

  • How to get the data in order by date

    Hi,
    i am getting the data like bellow i need the data with out null values
    date     col1     col2     col3     col4
    16-Nov-11     23               
    17-Nov-11     12               
    18-Nov-11     321               
    19-Nov-11     23               
    20-Nov-11     132               
    16-Nov-11          2321          
    17-Nov-11          112          
    18-Nov-11          211          
    19-Nov-11          132          
    20-Nov-11          12          
    16-Nov-11               45     
    17-Nov-11               465     
    18-Nov-11               2123     
    19-Nov-11               132     
    20-Nov-11               65     
    16-Nov-11                    456
    17-Nov-11                    546
    18-Nov-11                    4656
    19-Nov-11                    566
    20-Nov-11                    564
    need out like below
    date     col1     col2     col3     col4
    16-Nov-11     23     2321     45     456
    17-Nov-11     12     112     465     546
    18-Nov-11     321     211     2123     4656
    19-Nov-11     23     132     132     566
    20-Nov-11     132     12     65     564
    Thanks in advance,
    Venkat.

    Hi, Venkat,
    user6552629 wrote:
    Hi,
    i am getting the data like bellow i need the data with out null values
    date     col1     col2     col3     col4
    16-Nov-11     23               
    17-Nov-11     12               
    18-Nov-11     321               
    19-Nov-11     23               
    20-Nov-11     132               
    16-Nov-11          2321          
    17-Nov-11          112          
    ...You may have noticed that this site noramlly compresses whitespace. As a result, it looks like col1 is present on every row, but col2, col3 and col4 are always NULL.
    Whenever you post formatted text on this site, type these 6 characters:
    \(small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing, so that your message can look like this:date          col1     col2     col3     col4
    16-Nov-11     23               
    17-Nov-11     12               
    18-Nov-11     321               
    19-Nov-11     23               
    20-Nov-11     132               
    16-Nov-11          2321          
    17-Nov-11          112          
    You want to take a table, that has multiple rows for the same dt, and produce a result set that has one row per dt.  That sound like a job for GROUP BY:SELECT     dt     -- DATE is not a good column name
    ,     MIN (col1)     AS col1
    ,     MIN (col2)     AS col2
    ,     MIN (col3)     AS col3
    ,     MIN (col4)     AS col4
    FROM     table_x
    GROUP BY dt     -- See note below
    ORDER BY dt
    Depending on your data and your requirements, you may need to use TRUNC (dt) in all 3 places where I used dt above.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using.
    You'll get better replies sooner if you post this information every time you have a question.
    Edited by: Frank Kulash on Nov 15, 2011 10:37 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

Maybe you are looking for

  • File permission in Users/Shared?

    I Got Info from the Finder on the Users/Shared folder, unlocked the permissions with my password, and set Everyone to read-write then click on Apply to Enclosed Items down in the hidden menu at the bottom [is that a gear icon?] I did the same to the

  • My 4 gb ipod Nano is full yet there are only 20 songs on it. In summary, it just says "other" is taking up the space. Was fine one day and the next I got this. Help?

    Have had problems since downloading iTunes 10. First it moved all my iTunes music files to another location. Next, I lost all my songs on my iPod. I went to replace the music to the iPod that I'd lost, but it only allows me to add about 20 songs (on

  • Internal table when creating a class

    Hi everybody im defining parameters when defining a class one of the parameters is IT_MARA, of type MARA Ive declared a method - SELECT_DATA, where the code is SELECT * FROM MARA INTO TABLE IT_MARA.... When activating it Im getting the error - IT_MAR

  • Depreciation posting

    Hi, I want to calculate depreciation of assets according to the day when the Asset is capitalized on : If date <= 15th of the month, so calculate the depreciation for all the month If date > 15th of the month, so don't calculate depreciation fo this

  • 4th generation Nano won't charge with stereo.

    My 2nd generation just decided to die. I've had it integrated with my car stereo and it was working great until this morning when it just died. So, I decided to use the 4th generation that I had connect to my Bose system. To my surprise the Nano said