Getting path names

Hi
I was developing an application where I had to get the path for a file, So I wrote:
String s= file.getPath(); - this returned (for example): "C:\code\networking.txt".
How can I get this path as "C:/code/networking.txt".
The reason why I need to get "C:/code/networking.txt", is because if I create a string :
String d="C:\code\networking.txt". then I get compling errors.
I can only create Strings which have separators like "/" rather than "\". ( I could use "\\" , but this is not what I want to do)
So does anyone know how I can get the path as "C:/code/networking.txt".
(I am working on Windws)
regards

I used something like:
java.net.URL url = getClass().getResource("/path/file.txt");in order to bring in a file I needed. Have you tried something like that?

Similar Messages

  • How can I get the path name and rename it?

    I Hope someone who knows more about automator than I can help me out here. What I'm trying to do is get the path file name, while also changing part of it. Here is my example:
    I can get the path name with this "Get Path" script I found http://automatorworld.com/archives/get-path/all-comments/
    It does half the job so I just need to tweak it but know how. When I get the path this is what I'll get: /Volumes/Public/Creative Services/Campaigns/2010/NCDDiv-32CDV Upgrade/NCDDIV-32Versions.xls
    I need to remove the beginning part"/volumes" to "file://///nhmanmkt01"
    This is so I can send the path from our sever where we keep our files to my windows friends so they can open it.
    Thanks for any help you can provide!

    ok, make the following workflow.
    1. get selected finder items.
    2. run shell script
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #ADD8E6;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    for f in "$@"
    do
    echo "$f"|sed 's%/Volumes%file://///nhmanmkt01%'
    done</pre>
    set the script to accept input as arguments
    3. copy to clipboard
    save it as a finder plugin.

  • Getting the local full path name of a file from an item File Browser

    Hi all,
    I would like to get the local full path name, of a file selected from an item 'File browser'.
    I see in wwv_flow_files the column 'name', but actually it's a kind of id like 'F1542335/myFile.gif' for example.
    What i want is the local path of this file ("C:\Documents and Settings\All Users\....\myFile.gif").
    I hope this is possible??
    Anyway, thanks all for reading.
    Ludo

    Hello, thank you for the answer.
    Please understand that I searched before posting, and not ony 15 min.
    What i mean is that the value of a File Browser in an Apex applocation is something like 'F1542335/myFile.gif', but what I need is the local path location.
    And 'F1542335/' is not the local path location, i can't use it. Or maybe there is a way to convert it in a proper path name, such as "C:\Documents and Settings\....", but I don't think so.
    So my question is : how to get the local path name of a file in Apex?
    I'll answer if I find some good things.
    Thanks
    Ludo
    Edited by: user12945874 on 06-avr.-2010 3:59

  • How to get the loaded client sequence file path/name?

    I added a step in Process model, and wanted to get currently loaded client sequence file name/path. I used the variable of "SequenceFile.Path" but then I realized what I would get is the process model file path, not loaded client sequence file path/name. How can I get loaded client sequence file path/name?
    Thanks!
    Jacky

    I dont understand what you are trying to achieve.  Can you provide more information.
    If you are trying to dynamically load and run a client sequence file at run time you need to make a couple of calls to the TS API from inside the process model, Engine.GetSequenceFileEx to get a reference to your sequence identified by its pathname, and then Execution.ClientFile to tell the process model which sequence you want to run.
    Steve
    There are 10 types of people in the world that understand binary, those that do and those that don't.

  • Get file name/path of current .cfm file...

    i am going to make a "tracking" script for a website.  my idea is to add a <CFINCLUDE> to every .cfm file on the server (right at the end, so it would be easier to remove when im done), and have the script that is included add a record to a database that contains the file name/path of the .cfm file.  for example, index.cfm will include trackscript.cfm, and after the index.cfm is processed, a database will have a record in it containing the file name/path for index.cfm.
    i am new to coldfusion, but i think i have everything figured out, except how to get the name of the file that will be added to the database.  is there some kind of function or variable available that will give me the filename of the currently executing .cfm file?

    I don't think sticking a <cfinclude> call into every file is really a very good way of doing this.
    You should have a look at using onRequestEnd() for this sort of thing.
    There are various variables in the CGI scope which one can use to build the originating URL of the current request; CGI.script_name and CGI.query_string are probably the most helpful here.  One can resolve the underlying file system path form a URL using expandPath().
    Adam

  • How to get the full path name of a file

    Hey everybody, I'm new here and in Java.
    so I will explain my question by giving an example:
    I want to send file from the Desktop by the "Send to" on the popup menu to my program.
    I want to know how can I read the full path name and the file name, and show it on my text box.
    Thanx alot

    If this is a client side application then I'd say look into drag-n-drop tutorials.
    i.e. drag file to your application, action listener fires, create File object giving you full name and path of users action.
    If this is a web application then look into the "multipart/form-data" content type specifications on how to upload files.
    i.e. user specifies file from <input type='file' ... /> type, submits, servlet receives data and recreates file locally on application server side.
    If you are thinking that all you need to send a file to a program is the full path and name in a textbox its a little bit more complicated then that.
    Good luck, hope that helps!

  • Get file name and path from  adf inputFile

    Hi,
    I use adf's inputFile component. I need to get the file name and filePath. Does anyone knows how to do that?
    Thanks in advance

    You may bind the value to an UploadedFile object and get the name from this object.
    You may use a valueChangeListener backin bean method or a managed bean.
    Here the code i just write for something similar. Note that i'm not able to test it because of a bug in 10.1.3.1 with inputFile and web.xml parameters. I still waiting for the patch.
    public void uploadedFile(ValueChangeEvent valueChangeEvent) throws IOException,
    Exception {
    final int BUFFER = 2048;
    byte data[] = new byte[BUFFER];
    int currentByte;
    String fileName;
    UploadedFile uploadedFile =
    (UploadedFile)valueChangeEvent.getNewValue();
    if (uploadedFile != null) {
    String mimeType = uploadedFile.getContentType();
    if (mimeType == "application/x-zip-compressed") {
    // get the uploaded file as a zip file
    ZipFile zipFile = new ZipFile(uploadedFile.getFilename());
    // verify the zip archive contains only one entry
    if (zipFile.size() != 1) {
    FacesContext context =
    FacesContext.getCurrentInstance();
    ResourceBundle errorMessage =
    ResourceBundle.getBundle(context.getApplication().getMessageBundle());
    Exception ZipFileContentException =
    new Exception(errorMessage.getString("error.fileUpload.zipFileContent.moreThanOneEntry").replace("{0}",
    String.valueOf(zipFile.size())));
    throw ZipFileContentException;
    // get the entries in the zip file even it is only one
    Enumeration zipFileEntries = zipFile.entries();
    // Process each entry
    while (zipFileEntries.hasMoreElements()) {
    // grab a zip file entry
    ZipEntry entry =
    (ZipEntry)zipFileEntries.nextElement();
    // check the entry is not a directory
    if (entry.isDirectory()) {
    Exception ZipFileContentException =
    new Exception(JSFUtils.getStringFromBundle("error.fileUpload.zipFileContent.isDirectoryInsteadFile"));
    throw ZipFileContentException;
    File destFile = new File(entry.getName());
    Magic magic = new Magic();
    // getMagicMatch accepts Files or byte[],
    // which is nice if you want to test streams
    MagicMatch match = magic.getMagicMatch(destFile, true);
    if (match.getMimeType() != "application/xml") {
    Exception ZipFileContentException =
    new Exception(JSFUtils.getStringFromBundle("error.fileUpload.isNotXMLFile").replace("{0}",
    match.getMimeType()));
    throw ZipFileContentException;
    //TODO get the repository directory from classification-param.xml
    BufferedInputStream is =
    new BufferedInputStream(zipFile.getInputStream(entry));
    FileOutputStream fos = new FileOutputStream(destFile);
    BufferedOutputStream dest =
    new BufferedOutputStream(fos, BUFFER);
    // read and write until last byte is encountered
    while ((currentByte = is.read(data, 0, BUFFER)) !=
    -1) {
    dest.write(data, 0, currentByte);
    dest.flush();
    dest.close();
    is.close();
    zipFile.close();
    } else if (mimeType == "application/xml") {
    String currentEntry = uploadedFile.getFilename();
    File destFile = new File(currentEntry);
    BufferedInputStream is =
    new BufferedInputStream(uploadedFile.getInputStream());
    FileOutputStream fos = new FileOutputStream(destFile);
    BufferedOutputStream dest =
    new BufferedOutputStream(fos, BUFFER);
    // read and write until last byte is encountered
    while ((currentByte = is.read(data, 0, BUFFER)) != -1) {
    dest.write(data, 0, currentByte);
    dest.flush();
    dest.close();
    is.close();
    } else {
    Exception ZipFileContentException =
    new Exception(JSFUtils.getStringFromBundle("error.fileUpload.isNotXMLFile").replace("{0}",
    mimeType));
    throw ZipFileContentException;
    }

  • Get the name and path of the calling JSP

    Hi all,
    I have a code structure like this
    class MyBaseServlet extends HttpServlet{
    doPost(){processRequest();}
    doGet(){processRequest();}
    processRequest(req, resp){}
    myPrivateMethod(req,resp){
    //I want the name of the JSP which invoked the servlet that extends this(MyBaseServlet) here
    class MySerlvet extends MyBaseServlet{
    processRequest(req, resp){}
    I have a JSP which submits in the <FORM> action calls MyServlet. Since MyServlet extends MyBaseServlet, and this has the doPost() and doGet() methods, the control goes here first, and then since MyServlet has overridden the processRequest() method , the control comes here.
    My query isthat, while in MyBaseServlet (either in doPost() or doGet(), say I call myPrivateMethod(), is there any way here, inside myPrivateMethod() to get the name of the JSP which called MyServlet.
    Note:
    The constraint here is that we are not in a position to include any code into either the JSP or MyServlet. I'm running this in a J2EE environment on Websphere.
    Thanks in advance.

    You can use the methods of the HTTPServletRequest class to get the URI/URL info...for example request.getRequestURI() /URL()/ServletPathInfo()
    http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/http/HttpServletRequest.html

  • GET FILE NAME C:\temp\ADIBO.txt

    Hi,
    How to get file name?
    I used Get_File_NAME, but I'am getting an error.
    lv_lfilename is not the type LOGICAL_FILENAME
    C:\temp\ADIBO.txt
    I need to get  ADIBO ??
    tnh, Adibo..:)
    I am using this code to download file and after that I need to get FILE_NAME:
    DATA:  lv_lfilename TYPE string.
    PARAMETERS:
      pa_lfile TYPE zlocalfile
               DEFAULT 'C:temp'.
        CONCATENATE pa_lfile ''INTO lv_lfilename.
        CALL FUNCTION 'GUI_DOWNLOAD'
             EXPORTING
                  filename = lv_lfilename
                  filetype = 'ASC'
             TABLES
                  data_tab = it_billit_down.
        IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.

    Hii..
    You have to Maintain the Logical filenames and their Physical Paths in Tcode FILE.
    Then create a program like this..
    REPORT  ZSEL_FILES1.
    DATA : V_LOGFILE TYPE STRING.
    DATA :V_PHYFILE TYPE STRING.
    DATA : ITAB TYPE TABLE OF SCARR.
    START-OF-SELECTION.
    SELECT * FROM SCARR INTO TABLE ITAB.
    **To get the Physical file based on the Logical file names - Maintained in Tcode FILE
    CALL FUNCTION 'FILE_GET_NAME'
      EXPORTING
       CLIENT                        = SY-MANDT
        LOGICAL_FILENAME              = VlOGFILE
      OPERATING_SYSTEM              = SY-OPSYS
      PARAMETER_1                   = ' '
      PARAMETER_2                   = ' '
      PARAMETER_3                   = ' '
      USE_PRESENTATION_SERVER       = ' '
      WITH_FILE_EXTENSION           = ' '
      USE_BUFFER                    = ' '
      ELEMINATE_BLANKS              = 'X'
    IMPORTING
      EMERGENCY_FLAG                =
      FILE_FORMAT                   =
       FILE_NAME                     = V_PHYFILE
    EXCEPTIONS
      FILE_NOT_FOUND                = 1
      OTHERS                        = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    **To download the file to PC.
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
      BIN_FILESIZE                    =
        FILENAME                        = V_PHYFILE
       FILETYPE                        = 'ASC'
      APPEND                          = ' '
       WRITE_FIELD_SEPARATOR           = 'X'
      HEADER                          = '00'
      TRUNC_TRAILING_BLANKS           = ' '
      WRITE_LF                        = 'X'
      COL_SELECT                      = ' '
      COL_SELECT_MASK                 = ' '
      DAT_MODE                        = ' '
      CONFIRM_OVERWRITE               = ' '
      NO_AUTH_CHECK                   = ' '
      CODEPAGE                        = ' '
      IGNORE_CERR                     = ABAP_TRUE
      REPLACEMENT                     = '#'
      WRITE_BOM                       = ' '
      TRUNC_TRAILING_BLANKS_EOL       = 'X'
      WK1_N_FORMAT                    = ' '
      WK1_N_SIZE                      = ' '
      WK1_T_FORMAT                    = ' '
      WK1_T_SIZE                      = ' '
    IMPORTING
      FILELENGTH                      =
      TABLES
        DATA_TAB                        = ITAB
      FIELDNAMES                      =
    EXCEPTIONS
      FILE_WRITE_ERROR                = 1
      NO_BATCH                        = 2
      GUI_REFUSE_FILETRANSFER         = 3
      INVALID_TYPE                    = 4
      NO_AUTHORITY                    = 5
      UNKNOWN_ERROR                   = 6
      HEADER_NOT_ALLOWED              = 7
      SEPARATOR_NOT_ALLOWED           = 8
      FILESIZE_NOT_ALLOWED            = 9
      HEADER_TOO_LONG                 = 10
      DP_ERROR_CREATE                 = 11
      DP_ERROR_SEND                   = 12
      DP_ERROR_WRITE                  = 13
      UNKNOWN_DP_ERROR                = 14
      ACCESS_DENIED                   = 15
      DP_OUT_OF_MEMORY                = 16
      DISK_FULL                       = 17
      DP_TIMEOUT                      = 18
      FILE_NOT_FOUND                  = 19
      DATAPROVIDER_EXCEPTION          = 20
      CONTROL_FLUSH_ERROR             = 21
      OTHERS                          = 22
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    <b>reward if helpful</b>

  • How to get the name and value of an attribute on a node/element that is not a child

    Hello,
    Can someone shed some wisdom on how I can compare 2 xml nodes for differences.
    My main challenge is I need to use the attributes/values of 'ProductDescription' and 'Features' as 'key' to identify the same node in
    another doc with the same layout, but different content.
    I am having trouble getting the name of the attribute on the node, 'ProductDescription' and 'Features'.  I can only seem to get the node names, but not the attributes on the node.  I need the name, because it can be different from doc to doc, so
    I can't hardcode this.
    Can someone please help with how to retrieve an attribute name/value on a node that is not a child.  Here's an example of what
    my xml looks like:
    DECLARE
    @myDoc1 xml
    ,@mydoc2 xml
    DECLARE
    @ProdID int
    SET @myDoc1 ='<ProductDescription ProductID="1" ProductName="Road Bike">
    <Features  featureID  = "1" featureName = "body">
      <Warranty>1 year parts and labor</Warranty>
      <Maintenance>3 year parts and labor extended maintenance is available</Maintenance>
    </Features>
    <features featureID = "2" featureName = "seat">
      <Warranty>1 year parts and labor</Warranty>
      <Maintenance>2 year parts and labor extended maintenance is available</Maintenance>
    </Features>
    </ProductDescription>
    SET @myDoc2 ='<ProductDescription ProductID="1" ProductName="Road Bike">
    <Features  featureID  = "1" featureName = "body">
      <Warranty>2 year parts and labor</Warranty>
      <Maintenance>3 year parts and labor extended maintenance is available</Maintenance>
    </Features>
    <features featureID = "2" featureName = "wheel">
      <Warranty>1 year parts and labor</Warranty>
      <Maintenance>2 year parts and labor extended maintenance is available</Maintenance>
    </Features>
    </ProductDescription>
    I need to compare the attributes of 'ProductDescription' and 'Features' from @mydoc1 against @mydoc2 to see if they are the same based on those 2 nodes first.  If they are, then i want to show the difference in the child elements. 
    This will eventually be an outer join to give me the differences betw the 2 docs based on those key values (node attributes).
    I used node('//*') for the path, and value('local-name(../.)', 'varchar(50)') as element
    ,value('.[not(@xsi:nil = "true")]','VARCHAR(255)') AS new_value
    ...etc...
    but that only gives me the node names, and the child elements.  It does not give me back the attribute names and values from the node itself.
    Thanks in advance for your help.
    cee

    Are you looking for something like this:
    DECLARE @myDoc1 xml
    SET @myDoc1 ='<ProductDescription ProductID="1" ProductName="Road Bike">
    <Features  featureID  = "1" featureName = "body">
      <Warranty>1 year parts and labor</Warranty>
      <Maintenance>3 year parts and labor extended maintenance is available</Maintenance>
    </Features>
    <Features featureID = "2" featureName = "seat">
      <Warranty>1 year parts and labor</Warranty>
      <Maintenance>2 year parts and labor extended maintenance is available</Maintenance>
    </Features>
    </ProductDescription>'
    SELECT T.c.value('local-name(.)', 'nvarchar(50)') AS name,
           T.c.value('.', 'nvarchar(50)')  AS value
    FROM   @myDoc1.nodes('ProductDescription/@*') AS T(c)
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Logical file name or logical path name incorrectly defined

    Dear All,
    We are doing archival in our IDES for test purpose before we do it to our Production.
    Steps Performed
    Copied AM_ASSET archive object to ZAM_ASSET
    Logical Path
      Logical path    ZAM_ASSET
      Name            Asset
      Syntax group    UNIX       Unix compatible
      Physical path   /archive/test/<FILENAME>
    Logical File Name
       Logical file    ZAMASSET
       Name            Asset
       Physical file   FI_<MONTH>_<DAY>.txt
       Data format     ASC
       Applicat.area   AM
       Logical path    ZAM_ASSET
    But when we run the WRITE though SARA , in the job log we get the following
    Logical file name or logical path name incorrectly defined
    When generating a file name for an archive file that is to be created, the system determined that the logical file name FIAA_ARCHIVE_DATA_FILE or the logical path name ARCHIVE_GLOBAL_PATH  was defined incorrectly.
    But we have maintained a Logical name  ZAMASSET , so we are unable to change the location of archived file and as well as the format.
    So is there any setting we need to maintain apart from the logical file name and logical file path.
    Suggestions are highly appreciated.
    Thanks in anticipation

    hi,
    follow this steps :
    - transaction SARA
    - enter authorization objects, eg SD_VBAK
    - hit button CUSTOMIZING
    - Archiving Object-Specific Customizing: execute Technical Setting
    - field Logical File Name enter or select ARCHIVE_DATA_FILE
    - leave CONTENT REPOSITORY as blank if you are not using 3rd party for storing (eg. IBM Tivoli)
    - back to customizing
    - from Basis Customizing, execute : Cross-Client File Names/Paths
    - on Logical FIle Path Definition, highlight (select) ARCHIVE_GLOBAL_PATH on the right pane
    - double click on the Assignment of Physical Paths to Logical Path on the left pane
    - double click on OS used, eg. UNIX, define Physical Path where archive file (on WRITE process) will be stored
    - save changes made
    - double click Logical File Definition, Cross Client on the left pane
    - double click ARCHIVE_DATA_FILE on the right pane
    - make sure that logical path is already set to ARCHIVE_GLOBAL_PATH
    - save changes made
    this setting also can be done using transaction FILE
    we have experienced on this case using SAP standard archiving (SARA, SARI) and everything is fine with this setting above.
    hope it help you.
    rgds,
    Alfonsus Guritno

  • How do U to get the names of all files in a directory?

    Is there a simple way to get all names of the files in a directory and put them in an array of Strings? Sounds simple, but I don't have a clue how to do this. Thanks.

    Hi Kindoo,
    Create a instance of File object using the path of the Directory
    File fileDir = new File(directoryPath);
    To get the List of all the files in the directory use
    String[] strFiles = fileDir.list();
    This will solve your problem,
    Cheers
    Nagaraj

  • How to get path to file variable with applescript

    I've tried:
    `set file_path to path of myfile`
    but it's giving me error:
    `error "Finder got an error: Can’t get path of document file ..."`

    Code is:
    set theFolder to (choose folder with prompt "Select the start folder")
    set file_list to every file of theFolder
    repeat with myfile in file_list
        set file_name to name of myfile
        set file_path to path of myfile
        log (file_path & "/" & file_name as string)
    end repeat

  • Invalid File Path Names in Mac OS X

    Hello,
    I am trying to create a Javascript in Mac OS X 10.4.11, however I am having some trouble with what characters are valid in file path names in Mac OS X. Does anybody know where I can get a list of invalid characters that cannot be used in a file name?
    Thanks,
    james

    Any character other than a colon can be used in the name, but additional characters and names may be handled differently if you are interacting with the UNIX shell in the script.
    (30221)

  • How to get path or parent folder

    Hello
    I'm overriding method extendedPreAddRelationship on class S_Relationship.
    My purpose is to check whether the document is being put in the correct path or not.
    I can get folder name and document name using following code:
    AttributeValue av;
    av = def.getAttribute(Relationship.LEFTOBJECT_ATTRIBUTE);
    S_PublicObject folder = (S_PublicObject) av.getPublicObject(this.getSession());
    av = def.getAttribute(Relationship.RIGHTOBJECT_ATTRIBUTE);
    S_PublicObject document = (S_PublicObject) av.getPublicObject(this.getSession());
    What I need is the whole path (or at least the parent folder). Can I get path somehow? Or should I try to search parent folders?
    Jaska

    My purpose is to check whether the document is being put in the correct path or not.Hi,
    I had a similar problem - I needed to compare the path of current folder with path from parameters. Because I wasn't be able to get the path of folder, I did it in reverse way, comparing the folders. To get folder from path I needed getRootFolder method, which wasn't in server-side classes, so I extend S_TieFolder class:
    * Analogy of LibrarySession.getRootFolder().
    public static S_Folder getRootFolder(S_LibrarySession session)
    throws IfsException
    S_Folder folder = null;
    try
    Collection c = session.getValueDefaultCollection();
    S_ValueDefault vd = (S_ValueDefault)c.getItems("RootFolder");
    AttributeValue av = vd.getPropertyValue();
    folder = (S_Folder)av.getPublicObject(session);
    catch(Exception e)
    throw new IfsException(21020, e, session);
    return folder;
    In extendedPreAddItem method of S_TieFolder:
    S_Folder paramFolder = (S_Folder)getRootFolder(session).findPublicObjectByPath(folderPath);
    if( this==paramFolder ) ...
    Radek
    [email protected]

Maybe you are looking for