Concatenate a path and a Filename (different Filesystems)

Hi,
i've got the following problem:
I have 2 Strings. One contains an absolute Path to a Folder (not a File!), the other one contains a File Name. Now I want to concatenate this 2 Strings to an absolute Path to this File. Problem is:
Example:
String1 contains c:\
String2 contains blah.txt
Concatenation is: c:\blah.txt
This is ok.
Example 2:
String 1 contains c:\test
(Note the missing backslash)
String2 contains blah.txt
Concatenation is: c:\testblah.txt
This is INCORRECT.
The simple solution is to test whether there is a backslash at the end of the string or not.
But here i've got the problem with other file Systems. If the String is /homes/blah and I put a backslash at the end I'll run into trouble ;)
Is there a smart way to solve this or do I have to test every alternative?
Thanks in advance for answers!
Yours,
Sebastian

You can always append "/" after the folder name even if there's already a slash- or backslash at the end (and if the file really exists, of course), no matter what OS.
String folderA = "C:\\Temp";
String folderB = "C:\\Temp\\";
String folderC = "C:/Temp/";
String file = "test.txt";
System.out.println(new File(folderA+"/"+file).exists());
System.out.println(new File(folderB+"/"+file).exists());
System.out.println(new File(folderC+"/"+file).exists());All should return true if C:\Temp\test.txt is present.

Similar Messages

  • Finding the ReportRepositoryPath and Report Filename

    I was wondering if the report repository path and report filename of files sent to the report manager are stored somewhere in a table. It seems as if a select statement would be easier than finding the psreports/dbname/data/process id/process name_process instance id.extension. Any help would be great, thanks!
    BTW: I am wanting the physical path

    You could start to query the table PS_CDM_LIST, of course, you can join it with other Peoplesoft tables, like PS_CDM_DIST_NODE, depending of what you need exactly.
    Nicolas.

  • Finding of the Logical and Physical filename,Logical and Physical Path

    Hello All
    Where and how can I find the below details in an SAP server
    Logical filename:
    Physical filename:
    Logical path:
    Physical path:
    Regards
    Kalyani

    hi
    Physical file is what you see from the OS level.
    Logical file is what ABAP code can call certain functions to read/write.
    Transaction FILE would link them together. Typically the logical path ends with "<FILENAME>", and the logical file refers to the logical path.
    To extract the physical path from the logical path name
    DATA: lf_mandt TYPE sy-mandt,
    lf_opsys TYPE sy-opsys.
    lf_mandt = sy-mandt.
    lf_opsys = sy-opsys.
    To extract the physical path from the logical path name
    CALL FUNCTION 'FILE_GET_NAME'
    EXPORTING
    client = lf_mandt
    logical_filename = p_unix
    operating_system = lf_opsys
    IMPORTING
    file_name = gwa_input
    EXCEPTIONS
    file_not_found = 1
    OTHERS = 2.
    IF sy-subrc EQ 0.
    Concatenating the physical path and the input unix file name
    CONCATENATE gwa_input p_file INTO gf_file .
    ENDIF.
    You need to tak ehelp of ABAPer for this
    Check the link
    http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3deb358411d1829f0000e829fbfe/frameset.htm
    Regards

  • File dialog box: how get full path and filename (firefox 3.0 problem)

    Hi,
    I have a smilar problem then discussed in this thread: file dialog box: how get  full path and filename
    Now this solution doesn't seem to work in firefox 3.0,I only get the filename but not the full path.
    I have tried to solve this problem by adding *"netscape.security.PrivilegeManager.enablePrivilege("UniversalFileRead");"* in a javacript function but that doesn't do the trick
    Although when i tested it local it does work.
    Any idees how to solve this?
    Best Regards
    Stijn

    Actually, that is strange and scarry. With 20% of the browser market share they decide to behave like Microsoft did in the past - they want to decide what users need and what they do not need. With 3.0 I have a real problem with some of my applications. They are all tested in IE6, IE7, FF2.0 and they all work the same way (they even work with Opera and Safari). Now, I will for sure not go there and make it work for 3.0, just because 2 out of 200 users use FF3.0. Up to now I have always recomended FF as the best browser. 3.0 causes my opinion to change completely. Competition is always good but it is a question if it is good if we have 20 different browsers out there with equal market shares.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • Path and filename in footer

    If it is possible, how do I cause Acrobat 9 to report the current path and filename in the footer?
    Thanks!

    In a document-level JavaScript, add the following code, outside of a function definition:
    // Code in document-level JavaScript
    getField("PATH").value = path;
    where "PATH" is the name of a read-only text field that you've added to the bottom of each page.

  • Is it possible to set default path and filename to the upload UI element  ?

    Hello All,
       Can some advise on if its possible to set a default path and filename to the upload ui element ? I will like to set a default path and filename to be uploaded to the upload UI. The user will then have the option of using that path or clicking on the browse to set another location.
      Any suggestions or advise ? Thank you very much.
    from
    Kwok Wei

    Hello VS,
      So to confirm, from your opinion, you feel that its not possible to have my upload UI elememt to be displyed on the screen with the path and filename preloaded ?
    Btw, do you have an email that I can reach you at ?
    from
    Kwok Wei

  • How do I get the full path and filename of the current document?

    I'm writing a format plug-in. How do I obtain the full path and filename of the current image (document) from within my plug-in? Any help would be greatly appreciated!

    I actually just figured this out. For anyone else who would like to know, check out the propetizer sample code in the photoshop sdk. It makes a "filter" plug-in that just spits out all the properties of the document you could ever want to know about. The function I used to get the full path and filename of the current document is PIGetDocumentName(). I hope this helps someone eventually...

  • File dialog box: how get  full path and filename

    Hello All
    i have a problem to save the full path and filename with file dialog box.
    I want to save full path and filename in the database for creating a link to a file.
    I use a file-dialogbox to choose a file.
    I see in the textfiled something like this
    \FULLPATH\filename.ppt
    but when i save the textvalue in the database or look at the seesionvalue I see
    this:
    F2087258868/filename.ppt
    but I need the full path to create a link. How I can get?
    I use version 2.2.1..
    Thanks
    Putcho

    Hi Putcho,
    You can create some javascript that puts it into a hidden item.
    In HTML Form Element Attributes: onChange="$x('P15_X').value=$x('P15_FILE').value;" Then create another process that stores the value of the hidden item in your own table...
    I quickly made an example with a normal text item, so you see it copies itself to the other box: http://apex.shellprompt.net/pls/apex/f?p=286:15
    Hope that helps,
    Dimitri
    http://dgielis.blogspot.com

  • Sort by Path and Filename - What does a guy have to do?

    Hello all,
    First post here and such, but as the title reads. I have been using iTunes since early versions of 7 when I aquired my used 2gen Mini.
    In a past incident where people were attaching viruses to the ID3 Tags (see: http://en.wikipedia.org/wiki/Talk:ID3#Virusesin_ID3tags) I took the liberty (stupidity) of stripping all my ID3 tags from my music directory due to that security fault at the time, but also because all of them (the tags) were horridly inputted to the files.
    As iTunes users we can see the bad mistake I made, so now when I add a folder/directory to iTunes they just get sent to the bottom of the iTunes 'music list'.
    'Sort by path and Filename' would do wonders in organization of these untagged files. When adding an entire genre or folder, all **** breaks loose and there are the typical 40 tracks of '01 - songname' '02 - songname' and so on.
    This is where the rant part comes in. Here we are on Version 7.4.3.1 and Apple still hasnt added this minute feature to iTunes.
    I have to use Yahoo! Musicmatch (yuck) to sort and rename my files, only then to re-import them back into iTunes. I dont really care for that software (yahoo) for anything except sorting. Because it adds the actual folder to the viewable list and allows for batch renaming of directories and ID3 Tag renaming of entire albums/directories. I am not so concerned over the actual filename itself, but at least sorting by Path in iTunes would be nice so that I could give the files their proper ID3 Tags.
    Cmon Cupertino, this one isnt that hard.
    Thank you for your time.
    6

    You have several options -- two of which I'll outline below (neither built-in to iTunes, sorry)
    1) Use an external program to write ID3 tags based on the path/filename. One such program is "MP3Tag" (http://mp3tag.de/en)
    2) I wrote a program that with put the path in the Description field. You select the playlist -- then for every track in the playlist it changes the Description to the path. NOTE: I do NOT recommend that you select the "Library" playlist because it will overwrite existing descriptions for TV Shows, podcasts, etc. You can limit it to music by selecting the "Music" playlist.
    EXE version:
    http://home.comcast.net/~teridon73/itunesscripts/itunespathdescription.zip
    source code:
    http://home.comcast.net/~teridon73/itunesscripts/itunespathdescription.pl
    If you use my program, and it works for you, please consider a Paypal donation at my home page (http://home.comcast.net/~teridon73/itunesscripts/)

  • [svn] 4793: Fix bug SDK-17734 Path with width and height set different than path data has incorrect bounds

    Revision: 4793
    Author: [email protected]
    Date: 2009-02-02 11:20:06 -0800 (Mon, 02 Feb 2009)
    Log Message:
    Fix bug SDK-17734 Path with width and height set different than path data has incorrect bounds
    Fix: When calculating the bounds position we should take into account the implicit scaling factor actualSize/naturalSize. Also did some refactoring, getting rid of the protected method calculateTopLeft.
    QE Notes: None
    Doc Notes: None
    Bugs: SDK-17734
    Reviewer: Ryan
    tests: mustella gumbo/layout/GraphicElement
    Ticket Links:
    http://bugs.adobe.com/jira/browse/SDK-17734
    http://bugs.adobe.com/jira/browse/SDK-17734
    Modified Paths:
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/graphics/Ellipse.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/graphics/Path.as
    flex/sdk/trunk/frameworks/projects/flex4/src/mx/graphics/graphicsClasses/GraphicElement.a s

    Thank you so much for replying.
    Yes I have removed and reinstalled WMP.
    I had good results with the PD6 application installed on the default path onto the C: drive with the one exception that if the application was launched by accident and the user data path was not available, the PD6 application would blow away my custom user path registry settings. Now that I know what they are I have made a .reg file to repair my registry to my desired user data paths.
    Installing the application on the removable drive appeared to help prevent me from launching the application by accident and overwriting my registry with default user paths.
    So which is the less of the two evils?
    If the application directory is not available, windows media player still tries to launch the .msi for installing PD6.
    If I install the application to the C: drive but the user data to the removable drive, launching the PD6 application without the user data drive will still corrupt my registry settings for a user data path.
    Both these issues seem like a logical (if not easy) fix that should be done in the PD6 application and installation package. I mean really, cannot anyone tell me why windows media player is checking the PD6 application directory? Why in PD4 did we have an option control for setting the user data path from the PD4 application? Why is this option not in the PD6 application, just the installer?
    I am given a choice during installation to move the user data to another non default location. Why else would this be provided if not to accommodate my kind of request to store the user data into an alternate location other than “My Document”. Certainly Palm is not trying to force the users on how to protect and store their personal data?
    Post relates to: Centro (Verizon)

  • Path and filename containt the list of port used by OAS R3

    Could someone tell me the path and the file name that contains the port used by OAS R3.
    Thanks

    Previous versions used to have $OH/install/portlist.ini, this one doesn't but you can check ports used in....
    httpd.conf
    Check for directives
    Port
    Listen
    opmnctl status -l
    this will tell you the ports used by the OC4J, for rmi, ajp and jms for each one.
    And I think with this will do the trick, or if you need more, tell me.
    Regards.

  • To Find the path of the filename

    Hi Guys!
    Is it possible in D2K 2.1 to find the path of the filename entered by the user????
    My problem is: I use DDE package funct DDE.APP_BEGIN to open a filename (e.g. in this case any HTML file) enterd by the user. But I do not know where the IEXPLORE.EXE lies on each client machine. I think while using this funct, I need to give the full path of the module I want to open the file with. Because when I tried to use following func it gave me some error.
    DDE.APP_BEGIN('iexplore.exe c:\file_name');
    I hope the prob is clear.
    Thanks for the help.
    null

    I'm glad it worked for you too.
    The thing with batch files:
    Imagine you want to open to allow the user to open some files (with different extensions) with Wordpad.
    My previous solution would work if all the files had .wri extension.
    The directory for wordpad.exe is not the same for Windows 95 and Windows NT.
    My solution:
    create a batch file named vWordpad.bat:
    @echo off
    "c:\program files\accessories\wordpad.exe" %1In your form trigger,
    DDE.APP_BEGIN('vWordpad.bat c:\file_name');Make sure vWordpad.bat in located in a directory included in the OS path (c:\windows95, for example).
    Now, if you move your application to a Windows NT machine, all you have to do is change "c:\program files\accessories\wordpad.exe" to "c:\program files\windows nt\accessories\wordpad.exe". No need to change the fmb, recreate the fmx, etc...
    Everyone, feel free to comment on this approach.
    Pedro.

  • Unable to see the logical path and file created in FILE tcode from AL11 and unable to upload the file to this path from front end

    Hi Experts,
    I have created the logical path and filename in FILE tcode.I am trying to upload the pdf file to application server by using this path.But
    I am getting message like "Unable to open the file".Even I cannot find the this path in AL11 tcode.Kindly anyone advise how to upload pdf file using
    custom path and file created from FILE tcode.
    Thanks & Regards,
    Anusha.

    Hi Anusha,
    Please give as below.
    I forget to say you cannot open the PDF in AL11 and for that you need some configuration, i think it can be done using content server,not sure completely please wait for some more suggestions.
    Regards,
    Pavan

  • "Text on a path" and "paths" rasterised when printed from a PDF on an iGen

    I have just obtained from the printer the first proof of my book (printed on an iGen) and I'd like to find out where one of the problems lie. I'll ask the printer his opinion before second proof, but I don't like to annoy him unnecessarily.
    One of the chapters in the book has a lot of maps. I drew rivers by stroking a path, and named the rivers using 'Text on a Path' so that the text follows the curve of the river. Some of the maps have a pale background image on a different layer. And this is where the problem seems to lie.
    1. Rivers (and their names) appear normal on a map WITHOUT a background. By 'normal' I mean they look sharp. When magnified they seem to have been drawn as vectors.
    2. On maps WITH a background layer, 'Text on a path' appears very chunky (as if it has been rasterised at about 300 dpi) and paths (the rivers) appear to have the jaggies. Horizontal text does not appear to be affected.
    I can't be certain that (1) and (2) exactly define the problem, but it's as close as I can get at the moment.
    When I opened the original PDF file from which the book was printed, no matter how much I enlarge it, all paths and 'type on a path' retain their smoothness. i.e they are obviously vectors. However, I noticed when I opened the PDF in Acrobat 7 and tried to edit the 'text on a path', the PDF went haywire: the text I tried to edit disappeared, and other text frames on the page were shifted around.
    A sample PDF (6.7 MB, including an original two-page spread, and a scanned copy of the iGen print of the same), can be downloaded from:
    http://www.mediafire.com/download.php?oe4omuzoqzz
    Two questions:
    Q1: On the maps with a background image, is the rasterising of stroked paths, and 'text on a path' due to the iGen mishandling the file? Or might there be another explanation?
    Q2: Re Acrobat 7 mishandling my 'text on a path': is this a bug that has been fixed in later versions of Acrobat?
    To reproduce this bug do this: Open the PDF described above, and within Acrobat 7 select Tools > Advanced Editing > Touchup Text Tool. Then click inside the name "Georgina River", backspace to try and delete a letter, and the PDF should go haywire.

    Sandee: Almost certainly below the text, but I'd have to check them all.
    But before I do that, we'll have to go back a step. I can almost handle layers in InDesign, but didn't know they existed in PDFs. The printer printed from the PDF and as far as I can tell after a brief visit to HELP, there aren't any layers in the PDF. When I go to View > Navigation Tabs > Layers and click on the Layer Tab when it appears, there's nothing there; and all the items under Options are grayed.
    Q1: Why do I need a layer in a PDF? By not having layers, can that cause problems?
    Q2: Re Robert's suggestions: what do you mean by "move all the text to a top layer"? Within InDesign before I export to PDF?
    Q3: Is printing more foolproof when I export to PDF, if all my text is on the one layer in InDesign and that layer is above any images? There are several hundred river names, place names etc, sitting on lower layers, but if need be I'll move them all.

  • I have a question on paths and templates

    I have a question on how I should structure my site
    At my root directory on my server I have this set up.
    index.html
    /pages
         page1.html (all of these were created from my own template)
         page2.html
         page3.html
         and so on....
    /webReadyGraphics
    /css
    /library
    /templates
         genericTemplate.dwt
    Each folder has their own respective files in it.
    The problem I'm bumping into is relative and absolute paths in my DW templates/assest.  I will do my best to explain.
    I've create a menu with text that links to various pages.  An example would be a home button which always returns you to the index.html.  I turned that home button into an asset.  I've placed that asset into my genericTemplate.dwt. The link attached to the home button is a relative path and looks something like ../index.html.
    I have used my genericTemplate to create all my pages, even index.html.  So on my index page is my home button which tries to link to a parent directory ../index.html.  I decided to use absolute paths instead which is great on my local machine but when I go to upload to my server won't this be a problem?  As browsers will be looking for a local absolute path?
    How should I structure my website?  I've been thinking about putting all my pages at the root directory but that just gets mess looking.
    I hope I explained that well.  My understanding of web theory is a bit novice.
    Thanks!
    -Dweinin

    How do I do that? The pages which have the asset (button)  have different paths to get to the index.html...  some paths would be ../index others would be ../../index.html
    I don't know how to explain this.  I have 1 button.  that button is on 15 webpages.  Those pages are located at various directories from within my website.  So all their paths would be different but I only have 1 button.  So how do I put a relative path in there?
    I can put all the pages in 1 location so the button path would be the same.  That's not a problem BUT! I also have that button on my index.html page which is at the root of my site. 
    All of my pages would be located at root/pages/______.html.  The button would have a relative path of ../index.html
    The index is located at root/index.html  and that SAME button would have an incorrect path of ../index.html and return an error saying page not found.
    I want to keep the button an asset since I will likely be changing it's destination in the future or may want it to link a different page.  So I made the button an asset so that I when I do want to change it I only have to do it once and it updates across all my pages.
    Does that make sense?  Should I just put all my pages at the root?  Is that normal to do?  My root would start to look pretty mess with 15-20+ html pages.
    -Drew

Maybe you are looking for

  • Catching error messages in Webservice response

    Hi, The webservice I am trying to call from ABAP is throwing address not found exception which is caught by cx_ai_system_fault exception class. This class only returns <faultcode> and <faultstring> but not <ErrorCode> and <ErrorMsg> in <detail> node.

  • DBMS_LOB.GETLENGTH into bytes

    I am using Oralce 11.2.0.3. I am using DBMS_LOB.GETLENGTH to determine size of the CLOB . Is the value given by DBMS_LOB.GETLENGTH in bytes?

  • TS4268 Why won't my iMessage work? I always have to press "send as text" instead

    I just bought a new IPhone 4, and for a few days the iMessage did work but now all of a sudden it will not send no matter how good my service is, and then I have to press "send as text message" in order for it to send 

  • Photo mail problem

    photoshop elements 8 photo mail does not recognize outlook as default program even though it has been for several years, so photo mail does not work

  • Correlation

    hi all. i cant finish understand when to use a correlation in BPM. i was reading at Help Sap but the idea still is not clear. can anyone explain me with your own word what is a correlation and when for example i can use it. im watching  BpmPatternSyn