Converting URL to file path

I have a file in one of the folders of my webapp running in Tomcat. I need to convert the URL to the file to an absolute file path so that I can read it.
The URL looks like
http://localhost:28080/tester/custom/reports/transform.xsl
I tried creating a FIle object:
File file = new File(url.getFile());
But file.getAbsolutePath() returns
C:\tester\custom\reports\transform.xsl
It should be:
C:\Program Files\Apache Group\Tomcat 4.1\webapps\tester\custom\reports\transform.xsl
Any ideas?

ok, i succeeded in using URL to get stream as
follows:
String path = getBaseUrl() + "/" + "custom" + "/"
+ "reports";
String hostname =
InetAddress.getByName(InetAddress.getLocalHost().getHo
stAddress()).getHostName();
String urltest = "http://" + hostname + ":28080" +
path + "/transform.xsl";
URL url = new URL(urltest);
InputStream xsltStream =
url.openConnection().getInputStream();
where getBaseUrl() is a function that return the
context name
But another related question? How do I get the port
number.How do you get the port starting form where? From the URL? If so, URL has a getPort method.

Similar Messages

  • Lsmw converted file path

    hi all,
    i am loading sales order using lsmw direct input, and find a question. is it a must to specify a logical path and file name for the converted data at step specify file? at first, i didn't specify it and at the last step, i choose the flat file at my desktop in "File on presentation server with a physical file name", not the upper one "File on application server with a logical file name". and the result is "Table name not allowed". does that mean i have to use the logical one? any input will be appreciated.

    Hello Daniel Zhou,
    It is must to specify the file path in the step "Specify file", here you mentioned your flat file name in "Legacy data - On the PC (frontend)" based on that the system will create logical file path for converted data.
    Hope this helps.
    Regards,
    Arif Mansuri
    Reward if answer is helpful.

  • 'Open URL or file' - how to use a relative file path?

    I have a click box on a slide that I want to use to open an instance of a file (ie a PDF, a JPG, etc) in a new window, then when the user closes the window the Captivate demo continues.
    My plan is to distribute this file with the published project and have it sit in the same folder as the project files.
    I think that I have worked out all the processes to do this except how to correctly set up the click box.  In the click box properties I have 'Open URL or file' on success, but how to enter the information in the URL text box is challenging me.  An absolute path to the file on my computer works fine.  Can I specify a relative path so Captivate defaults to using a file stored in the same folder as the published project?
    I have attached a sample of the file I want to use.

    Hi there
    See if the link below helps.
    Click here to view
    Cheers... Rick
    Helpful and Handy Links
    Captivate Wish Form/Bug Reporting Form
    Adobe Certified Captivate Training
    SorcerStone Blog
    Captivate eBooks

  • Convert file path in application server as link

    How can we convert file path in application server as link to send email.
    Thanks
    Suresh

    Your app server folders have a mappable location on your network, e.g,
    server\path\filename.  Use an HTML anchor tag and build the link with code.  You'd be better off storing files on a file server (write to a mapped location from the app server) and link to there (same process).

  • Loading JSON files from URLS/File Paths into a After Effects

    Basically, I want to make a script in which the user enters a file path or URL of a JSON file, the file is loaded and the user can manipulate the data in various ways within After Effects.
    I got as far as writing a script that requests the data and logs it into the console but it will only work in Extendscript. I'm using Extendables which was built for indesign so that may be the problem.
        #include Extendables/extendables.jsx
        var url = "http://echo.jsontest.com/key/value/otherkey/othervalue";
        //Retrieve the data
        function retrieveData(_url){
            var http = require("http");
            var response = http.get(_url);
            var responseStr = JSON.stringify(response);
            var responseBod = JSON.parse(responseStr);
            var data = JSON.parse(responseBod.body);     
            $.writeln(data.key);
        retrieveData(url);
    When I run it in After Effects I get an error "Undefined is not an object" pointing to line 162 in errors.jsx which says:
    if (app.name.to('lower').contains("indesign")) {
    What exactly is happening here? Is there a better way to go about doing requesting JSON files?
    Thanks!
    EDIT: I should add that I tried removing the "$.writeln(data.key);" but am still getting the same error.

    The line that generates the error tries to test whether the targetted application is InDesign, and the test is not so good because in other apps the test may generate an error.
    (For AfterEffects, the object 'app' exists [object Application] but it doesnt have a 'name' property, so app.name.xxx is wrong).
    I don't know of a test that would work for any app. For After Effects, "if (app.effects instanceof Array)" might work, not sure.
    If the script is meant to target AfterEffects only you can simply omit the condition.
    Xavier

  • Jar files - convert url to a file

    Hi,
    I'm trying to create a jar file. The name of the package is Multimedia and theres a folder in that called Sound. It creates the jar file fine but I can't access the audio files. I'm using the getResource() method. That returns a url. I need to convert this to a File object. How do I convert it?
    url = testSound.class.getResource("/Multimedia/Sound/"+audioFiles[lsClips.getSelectedIndex()]);
    uri = new URI(url.toString());
    System.err.println("URI "+uri.toString());
    System.err.println("URL "+url.toString());
    soundFile = new File(new URI(url.toString()));This is the output:
    URI jar:file:/C:/PROJECT4/y.jar!/Multimedia/Sound/DMathews.wav
    URL jar:file:/C:/PROJECT4/y.jar!/Multimedia/Sound/DMathews.wav
    Please,please help. I've to hand up this project in the morning.
    Roseanne.

    Thanks so much for the fast answers!
    My code does compile ok. I get a nullPointer exception though - because the file hasn't loaded.
    Thanks Val also.
    In my program I was actually converting the file to an AudioInputStream.
    How would I convert an inputStream to an audioInputStream??
    This is my code:
    is = this.getClass().getResourceAsStream("/Multimedia/Sound/"+audioFiles[lsClips.getSelectedIndex()]);
    //loadAudio(soundFile);
          loadAudio(is);
    public void loadAudio(InputStream is)
        try
          //audioInputStream = AudioSystem.getAudioInputStream(soundFile);
          audioInputStream = new AudioInputStream(is,null,null);
          audioFormat =audioInputStream.getFormat();
    I get this error
    C:\PROJECT4>javac Multimedia/*.java
    Multimedia/testSound.java:402: cannot resolve symbol
    symbol : constructor AudioInputStream (java.io.InputStream,<nulltype>,<nulltype
    )location: class javax.sound.sampled.AudioInputStream
    audioInputStream = new AudioInputStream(is,null,null);

  • Common URL format for sharing file paths between Mac and Windows?

    Hi -
    I have to integrate several Macs into a Windows environment. We need to be able to copy and paste file paths to share between all machines. Is there a common URL format that can be used between the platforms?
    On Windows, I have:
    \\server\share\file
    On the Mac:
    smb://server/share/file
    Thank you for your help,
    Steve

    On Windows you have what is known as a "UNC".
    On the Mac, you have a "URL". It starts with the protocol to use "smb" then gives the path to the item using standard conventions.
    UNC is Microsoft mainly.
    The only way I know for Windows to use a URL is with an application like a web browser or ftp client.
    On the Mac, you can use UNCs but they must be modified as follows.
    In Terminal:
    smbclient \\\\servername\\sharename\\filename -U username
    And enter a password if prompted.
    Notice that you must double up the slashes. This is due to how UNIX shells treat the backslash.
    You will connect to the share, but it will only be in Terminal.

  • Problem launching Firefox from Windows with file path that contains space characters in the html file's file name

    We have a software application that programmatically launches the default web browser using the Windows shell execute function ("ShellExecuteA" in the "shell32.dll" library of the Windows API) along with a file path for a saved local html file that is to be displayed. In the case that FireFox is the default browser and the file path for the html file contains any space characters in the html file's file name, Firefox (in this case v7.01) will display an error message "File not Found..." and then will also proceed to open tabs for each of the individual words in the file name, launching as the URL path, each individual word appended to ".com".
    In the following example, the path "C:\KSSecOfState\Forms\Kansas Secretary of State - Filings and Forms.htm" when launched programmatically, resulted in the error message "File not Found...Firefox can't find the file at /C:/KSSecOfState/Forms/Kansas." and opened up browser windows for "http://www.secretary.com/", "http://www.of.com/", "http://www.state.com/", "http://www.and.com/", and attempted to launch "http://forms.htm". If the same file (renamed) is launched using the path string "C:\KSSecOfState\Forms\KansasSecretaryOfState-FilingsAndForms.htm" the file opens up correctly in Firefox. Clearly the presence of spaces in the file name is causing the problem.
    I should also note that either path (with or without space characters) works properly if pasted directly into the Firefox URL path menu bar for a live instance of Firefox. The test path strings I used were:
    C:\KSSecOfState\Forms\KansasSecretaryOfState-FilingsAndForms.htm
    C:\KSSecOfState\Forms\Kansas Secretary of State - Filings and Forms.htm
    Does anyone know anything about this problem or how to work around it (other than the obvious answer of taking the spaces out of the file name which is not possible for this application). It seems the problem is specific to Firefox. IE works properly if launched programmatically with spaces in the file name passed to it. I haven't tested other browsers yet.
    Thanks!

    If starting from ShellExecute works the same as starting from the command line then there are two options:<br>
    Put everything inside double quotes<br>
    '''C:\Program Files\Mozilla Firefox\>'''firefox.exe '''"c:\test\svg test.htm"'''<br>
    Convert to a valid url with file:// protocol and percentage-escaping the space<br>
    '''C:\Program Files\Mozilla Firefox\>'''firefox.exe '''file://c:\test\svg%20test.htm'''<br>

  • Converting uri to file

    URI map_uri = new URI("http://localhost:8080/img/ftr_2003.gif");
    i am trying to read an image and convert it to File object, cuz i want to attach the file to an email that i want to send out. but my client doesn't want to use absolute path that i have to use for creating a File object.... so i want to read an image from URL and convert it into File object and attach it to an email...
    is there anyone who knows how to do it?
    i'd appreciated it...

    i am trying to read an image and convert it to File
    object, cuz i want to attach the file to an email that
    i want to send out....So what does a File object have to do with this problem? I don't see any need for it. Look for the JavaMail attachment examples, you should find one that passes an InputStream as an attachment. Use the URL class to connect to that resource location and give you an InputStream that allows you to read the image directly from the web site into your e-mail.

  • How to get a list of file paths for all files used in a project

    I have a project in Premiere Pro CC which has a large number of bins.  A sequence in one of these bins uses files from other bins.  I am trying to find the locations of all each of the files used  in the project.
    1)  Obviously I can select each clip in the timeline and show in finder, but there a lot of clips
    2) The video usage associated with each file in the project would help.  However
               1.  I haven't found a way to display only clips that have video useage if all of the bins have not been expanded.
              2.  Video usage  shows usage for all sequences, so one would have to manually check the pull down for each file to see if it is used in the sequence in question.
    3) I tried exporting the project to final cut pro xml.  The path url gives me the information that I need.  For some reason, however, when I do the export only one clip's information is there, not the information for all of the other clips in the project.
    4) I tired an export for speedgrade and all of the file names are there.  However the paths are not. 
    Basically I want to find all of the files in the project and relocate them to a specific folder for that project.  There's got to be a way to do this but I'm not seeing it ....

    Thanks for the suggestion concerning the file path.  And certainly it would have been nice to have done this before beginning.  However this is a project that has been around for quite a while, and the files have been moved into different bins.  And now the project sequence is being revised.
    So the problem is, worded slightly differently, how can I search all of the bins for the files that are used just by this sequence, ignoring the files which are used by other sequences?  Or, how can I get a list of the file paths of the files that are used in the sequence?

  • I would like to convert a matlab file into a .dll and use it in LabVIEW. However, when I run the .dll in LabVIEW I get an error stating "... Procedure not found". What could this be? Can anyone help me...

    I wish to convert my Matlab files into .dll's so that I can use them in LabVIEW. I am using 'mcc' and 'mbuild' of Matlab to convert my .m files into .c and .dll.
    When I try to run the .dll's in LabVIEW, I get an error message in a modal window stating some required .dll or procedure is not found.
    How should I resolve this issue. Should I add any other Matlab .dll's in course of making my .dll?
    Please help in solving this issue... Thankyou very much.

    KJV wrote in message news:<[email protected]>...
    > When I run the matlab generated dll, it is stating 'matllb.dll not
    > found'. Is it that I should set the path for matlab\bin to include
    > all the dll's before I compile? When I make dll from C, it works fine
    > in LabVIEW. The problem is from .m to .dll. The problem also arises
    > when I convert my .m to .exe. The same error of 'matllb.dll not
    > found' comes over. Should I change my matlab compiler options or
    > something else? Please help me?
    I have the same question,I don't know how to use the matlab DLL file in labview,
    I hope someone can descripe the procedure in detail.

  • Error while saving the file path

    I have come across a problem in LSMW.
    In specify files step when I was trying to give the filename either in Presentation server or Application server and then save ,I am getting an error called 'No Logical Path has been specified'. In debugging I can see p_log_path and p_log_file are initial where as p_phys_file_compl has the file which is created automatically with standard naming convention. These 3 fields represents Converted Data files. I think the problem is with settings since the error is not happening to other users. If we double click 'Converted Data'  I can see Logical Path and Logical File fields. If I give the same file that is used for converted data it is asking me to create and if we agree then it creates and then we are able to save. So I think there is some setting changes or some other thing happened which at this stage I couldn't find out because I have not changed any settings. So can you please let me know if u have come across the same problem or if u know the solution.

    In the <b>specify files path</b> have u specified the paths correctly.
      5  Legacy data          On the PC (frontend)                                                                               
    VASG3 INPUT FILE               Y:VHDEV TEST FILE unlinked genl1.txt                      
                                            Data for one source structure (table)                       
                                            Delimiter tabulator                                                                               
    Order of fields as in source structure definition           
                                            With end of record sequence (text file)                     
                                            Codepage ASCII                                                                               
    Legacy data          On the R/3 server (application server)                                    
      5  Read Data            File for read data (application server)                                                                               
    5  Read Data                      /int/T82/conv/VNH_ASGN3.lsmw.read                                                                               
    A82      /int/A82/conv/VNH_ASGN3.lsmw.read                                      
                 P82      /int/P82/conv/VNH_ASGN3.lsmw.read                                      
                 T82      /int/T82/conv/VNH_ASGN3.lsmw.read                                                                               
    5  Converted Data       File for converted data (application server)                                                                               
    5  ConvertedData                 /int/T82/conv/VNH_ASGN3.lsmw.conv                                                                               
    A82      /int/A82/conv/VNH_ASGN3.lsmw.conv                                      
                 P82      /int/P82/conv/VNH_ASGN3.lsmw.conv                                      
                 T82      /int/T82/conv/VNH_ASGN3.lsmw.conv                                                                               
    Values for wildcard  Values for wildcard '*' in file names                                    
    Refer teh above u ahve to specifythe path till PROD system.
    I too  faced the saem problem.

  • LSMW - Logical File Path not pointing to Physical Path

    Hi All,
    I'm trying to upload some MIGO goods movement transactions through LSMW.  I'm to step 7, specifying files, and am getting the error "No logical file path has been specified.  I saw another thread which helped me, but I am still stuck after reading it. 
    Re: Error in Creation of Purchase Requisition through LSMW
    I have gone into transaction FILE and created the logical file name MM_GOODS_MOVEMENT, and set the physical file as the .lsmw.conv converted data file as the above thread says.  I also tried using the logical path LOCAL_TEMPORARY_FILES for the converted data, but I get the error telling me that the path does not point to a physical directory.  I then tried creating my own file path, and setting the path to my desktop where the source file is, and the same error occurred.
    Does anyone know why it is not recognizing the physical path maintained in the logical path?
    Thanks,
    J

    Thanks for both replies,
    I have full authorization across all transactions in the sandbox system I am working in, so that is not an issue.  I filled the logical path field in the MM_GOODS_MOVEMENT logical file with LOCAL_TEMPORARY_FILES, as well as trying my own created file path, and I recieved the same error for each.  Here is how the config is currently:
    Logical File Path Definition:  MM_GOODS_MOVEMENT
    Syntax Group: WINDOWS NT
    Physical path: C:\Documents and Settings\jchanski\Desktop\<FILENAME>
    or,
    Logical File Path Definition:  LOCAL_TEMPORARY_FILES
    Syntax Group: WINDOWS NT
    Physical path: C:\temp\<FILENAME>
    Logical File Name Definition: MM_GOODS_MOVEMENT
    Physical file: MM_MM_MIGO_INVUPLOAD.lsmw.conv
    Data format: ASC
    Applicat.area: MM
    Logical path: LOCAL_TEMPORARY_FILES or MM_GOODS_MOVEMENT
    Do you see any error with this Brajvir?  Thanks!

  • Logical file path problem in lsmw

    Hi folks,
    I created logical file  path in FILE tcode. its created and assigned physical file path to logical file path.
    then i am assigning that logical file path into lsmw step (specify file step).
    under specify file i am assigning into import data and convert data.
    once read data step completed read data must be save under this physical file but data is not saving under this path.
    can any one help me out this..
    1.can any one help how to create physical file in file tcode
    2.how to assigne that physical file to lsmw step specify file

    Hi Srikanth,
    There is no need to create the logical file path using the FILE transaction.
    Under Specify file step, you need to give your local file path in LEGACY DATA Section.
    Please check the below link in using the LSMW step by step.
    http://wiki.sdn.sap.com/wiki/display/ABAP/LSMWStepsin+Detail
    Hope this helps.
    Regards,
    Satish Kanteti

  • How to set default file path for save

    Hello all,
    I'm currently blocked on the below issue and is hoping to gain your help and insights.
    We have recently upgraded to InDesign CS6. Now when an INDD file created in an older version of INDD is opened in CS6, all the save dialogs would not default to the location of the original INDD file. Though if the same file is opened in the version of InDesign that created it, the save dialog goes to the proper location by default.
    Debugged using our custom plugin as a gate way, and found out that after InDesign CS6 performed the document upgrade/convert, the database for the converted document loses file information. i.e.  IDataBase::GetSysFile() returns nil. I think we can figure out some way to get the original file path. For example, we can intercept "kAfterOpenDocSignalResponderService", and get the original file path of the opened file from IDocumentSignalData. Though I haven't yet able to figure out a safe way to set this file path to the document, so that the save dialogs would by default point at this path.
    Utils<Facade::IWorkgroupFacade>()->InitDocumentAssetManagement(docRef, filePath) seems to do the right thing, but it seems to be quite intruding, and I'm afraid that it is overkilling and will cause bad side effect for the use case I'm looking for.
    So I'm wondering if anyone has any suggestions to achieve this without implementing/overriding the file save dialog.
    Thanks.
    -Jeff

    You should be able to avoid writing your own open-doc trap by using kDocBoss's IOpenedFileInfo to obtain the original file's path. It seems fairly reliable; the only time I've seen it come up empty is for an opened QuarkXPress document.
    I'm afraid I don't know of a sanctioned way to change IDataBase::GetSysFile() without going through the database's SaveAs machinery. Overriding this behavior might only be possible by replacing the regular Save dialog with your own.
    But if InitDocumentAssetManagement() is helping, maybe the workgroup/asset management approach is worth pursuing. Have you tried spying on that call in the debug app? You might be able to isolate and use one of the commands that it's invoking (IAMSPManager::BindAsset() / kSetAssetAttributesCmdBoss?) without all of the side-effects of the higher-level call.

Maybe you are looking for

  • Raw.plist trick not working anymore?

    Hi I edited my Raw.plist file to enable CoreImage to decode Sony DSC-R1 DNG files. It has always worked fine. Yesterday I tried to import a few new files and it does not work anymore. Older DSC-R1 DNG files are opening fine but new ones are not. I on

  • Update was terminated SAPSQL_ARRAY_INSERT_DUPREC

    Hi, We are trying to make our custom calculations in VA01, VA02 and because of this we need to update VBUP table. We updated the fields of xvbup and yvbup, but we receive an error "Update was terminated SAPSQL_ARRAY_INSERT_DUPREC".How

  • Custom Document & Custom Doc Legal Control Extraction into SAP BI

    Dear All, After all the business content for GTS was activated in GTS and SAP BI, the following configuration steps were taken in GTS to extract this data into BI for reporting: [1] Integration with Other mySAP.com Components > Data Transfer to the S

  • Activating adobe services in java stack (portal)

    hi, any one plz help me how to activate adobe services in java stack (portal)  (or)  do we have to seperately apply a add-on for adobe services . thanks, rahul

  • HELP WITH VIDEO FILES AND PUTTING ON ITUNESSS!!!!!!!!!!

    hey...i need help with my video ipod and itunes....i recently had sum problem with my ipod and i had to restore it...and when i hooked it up to itunes all the songs got back on it...its just that the videos never got updated with the songs....the vid