To Get The Path of A File

hi
i wanted to get the path of the file.i just need to get the path not the file.i wanted to do using swing.may be filechooser or tree. but i need to know how could i get tht if i know the exampl for this it would be useful for me ..

i need it in a way that like in windows explore.. so tht if i get the path of it i can use that in another class file.
anyway i am looking out in File class also.

Similar Messages

  • How 2 get the path of a file

    how 2 get the path of a file Using jsp
    i have tried getPath...but i'm geting the error
    The method getPath(String) is undefined for the type HttpServletRequest
    any idea how 2 get the path of a file

    You need ServletContext#getRealPath().
    API documentation: http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String)

  • How 2 get the path of a file Using jsp

    how 2 get the path of a file Using jsp
    i have tried getPath...but i'm geting the error
    The method getPath(String) is undefined for the type HttpServletRequest
    any idea how 2 get the path of a file

    You need ServletContext#getRealPath().
    API documentation: http://java.sun.com/javaee/5/docs/api/javax/servlet/ServletContext.html#getRealPath(java.lang.String)

  • F4 Help to get the path for a File source directory

    There are numerous function modules for browsing a particular file in desktop and getting the file path (including the fine name)  , like F4_FILENAME , KD_GET_FILENAME_ON_F4 , WS_FILENAME_GET etc. But can anyone tell me how to fetch only the directory path to the field were the F4 help is given. Actually the filename has to come in some other field in the selection screen. Is there separate funtion modules for these OR will changing parameters in the above function modules work?
    Pls Help....
    Also are there function modules for providing F4 help for getting the path to a file in application directory?

    Try this method CL_GUI_FRONTEND_SERVICES.
    It is a Global CLASS which is having different methods for different purposes
    see the documentation of it and use the methods of it
    see
    CL CL_GUI_FRONTEND_SERVICES
    Short Text
    Frontend Services
    Functionality
    The class CL_GUI_FRONTEND_SERVICES contains static methods for the following areas:
    File functions
    Directory functions
    Registry
    Environment
    Write to / read from clipboard
    Upload / download files
    Execute programs / open documents
    Query functions, such as Windows directory, Windows version, and so on
    Standard dialogs (open, save, directory selection)
    Example
    Determine the temp directory on your PC:
    DATA: TEMP_DIR TYPE STRING.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>GET_TEMP_DIRECTORY
    CHANGING
    TEMP_DIR = TEMP_DIR
    EXCEPTIONS
    CNTL_ERROR = 1
    ERROR_NO_GUI = 2.
    IF SY-SUBRC 0.
    Error handling
    ENDIF.
    flush to send previous call to frontend
    CALL METHOD CL_GUI_CFW=>FLUSH
    EXCEPTIONS
    CNTL_SYSTEM_ERROR = 1
    CNTL_ERROR = 2
    OTHERS = 3.
    IF SY-SUBRC 0.
    Error handling
    ENDIF.
    WRITE: / 'Temporary directory is:', TEMP_DIR.
    Notes
    The class CL_GUI_FRONTEND_SERVICES is based on the Control Framework. See the documentation for more information, in particular on CL_GUI_CFW=>FLUSH which must be called after many CL_GUI_FRONTEND_SERVICES methods.
    Migration Information
    The old file transfer model was based on function modules of the function group GRAP. The old features have been replaced by the class CL_GUI_FRONTEND_SERVICES. The following list contains the old function modules (italic) and the new methods (bold) that replace them:
    CLPB_EXPORT
    CLIPBOARD_EXPORT
    CLPB_IMPORT
    CLIPBOARD_IMPORT
    DOWNLOAD
    GUI_DOWNLOAD, dialog replaced by FILE_SAVE_DIALOG
    PROFILE_GET
    No replacement, use REGISTRY_* methods instead
    PROFILE_SET
    No replacement, use REGISTRY_* methods instead
    REGISTRY_GET
    REGISTRY_GET_VALUE, REGISTRY_GET_DWORD_VALUE
    REGISTRY_SET
    REGISTRY_SET_VALUE, REGISTRY_SET_DWORD_VALUE
    UPLOAD
    GUI_UPLOAD, dialog replaced by FILE_OPEN_DIALOG
    WS_DDE
    Obsolete: This function is no longer supported.
    SET_DOWNLOAD_AUTHORITY
    Obsolete: This function is no longer supported.
    WS_DOWNLOAD
    GUI_DOWNLOAD
    WS_DOWNLOAD_WAN
    Obsolete: This function is no longer supported.
    WS_EXCEL
    Obsolete: This function is no longer supported.
    WS_EXECUTE
    EXECUTE
    WS_FILENAME_GET
    FILE_SAVE_DIALOG, FILE_OPEN_DIALOG
    WS_FILE_ATTRIB
    FILE_SET_ATTRIBUTES, FILE_GET_ATTRIBUTES
    WS_FILE_COPY
    FILE_COPY
    WS_FILE_DELETE
    FILE_DELETE
    WS_MSG
    Obsolete: This function is no longer supported.
    WS_QUERY
    CD (current directory)
    DIRECTORY_GET_CURRENT
    EN (read/write environment)
    ENVIRONMENT_GET_VARIABLE
    ENVIRONMENT_SET_VARIABLE
    FL (determine file length)
    FILE_GET_SIZE
    FE (check if file exists)
    FILE_EXIST
    DE (check if directory exists)
    DIRECTORY_EXIST
    WS (determine Windows system)
    GET_PLATFORM
    OS (operating system)
    GET_PLATFORM
    WS_UPLDL_PATH
    Obsolete: This function is no longer supported.
    WS_UPLOAD
    GUI_UPLOAD
    WS_VOLUME_GET
    Obsolete: This function is no longer supported.
    Reward points if useful.

  • How can i get the path to config folder placed inside the jar file?

    Hi i have developed an RCP application using eclipse.
    In my application config directory is there.
    When i export my RCP application as JNLP Project the jar file is created which contains config folder inside it.
    When i download the application using java web start , how can i get the path to config folder placed inside the jar file?
    Will the config folder exists in local cache in my system?
    Help needed.
    -Deepak

    -- This works in CS6:
    tell application "Adobe InDesign CS6"
      set myDocument to active document
      set selectedRectangles to selection of myDocument
      set theGraphicsLink to file path of item link of (graphic 1 of (item 1 of selectedRectangles))
    --> "Macintosh HD:folder/folder/filename.tif"
    end tell

  • How to get the Path of the Current File using Import & Export File -Reg.

    Dear all,
    I have a mega (big) doubt. I have manually inserted the Figures from the figure folders. Now i need, fully automated. So How can I get the Figure path
    Example :
    PMString path = "E://development/Figures/";
    now i checked, How many subFolders is there in "path", get the All Subfolders and check to the Article Name.
    Example
    Article Name == subFolder name then get the Files from the SubFolders(E://development/Figures/ChapterF/*.eps files").
    now I paste the Document using to For Loop.
    Please any one can suggest me, How can We get the Path in SDK.
    Note:
    Should I have to create the relative path by myself?
    No method supplied in SDK to do this directly?
    Please I need a help of this Query as soon as posible.
    Thanks & Regards
    T.R.Harihara SudhaN

    http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/input_file.asp?frame=true
    When a file is uploaded, the file name is also submitted. The path of the file is available only to the machine within the Local Machine security zone. The value property returns only the file name to machines outside the Local Machine security zone. See About URL Security Zones for more information on security zones.
    i need to know on how to get the compelete path /directory of the filename
    using <input type="file"> tag You can't. Its a security thing.
    is there any other way to get an input file from a local host aside from <input type="file"> tag?No. Not using just html.
    You could always go into activex components, but thats different again.
    Cheers,
    evnafets

  • How to get the path when i select a directory or a file in a JTree

    How to get the path when i select a directory or a file in a JTree

    import java.lang.*;
    import java.io.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import java.awt.HeadlessException;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.Iterator;
    * @author Frederic FOURGEOT
    * @version 1.0
    public class JTreeFolder extends JPanel {
    protected DefaultMutableTreeNode racine;
    JTree tree;
    protected JScrollPane scrollpane;
    final static int MAX_LEVEL = 1; // niveau max de descente "direct" dans l'arborescence
    * Sous-classe FSNode
    * @author Frederic FOURGEOT
    * @version 1.0
    private class FSNode extends DefaultMutableTreeNode {
    File file; // contient le fichier li� au noeud
    * Constructeur non visible
    private FSNode() {
    super();
    * Constructeur par initialisation
    * @param userObject Object
    FSNode(Object userObject) {
    super(userObject);
    * Constructeur par initialisation
    * @param userObject Object
    * @param newFile File
    FSNode(Object userObject, File newFile) {
    super(userObject);
    file = newFile;
    * Definit le fichier lie au noeud
    * @param newFile File
    public void setFile(File newFile) {
    file = newFile;
    * Renvoi le fichier lie au noeud
    * @return File
    public File getFile() {
    return file;
    public JTree getJTree(){
         return tree ;
    * Constructeur
    * @throws HeadlessException
    public JTreeFolder() throws HeadlessException {
    File[] drive;
    tree = new JTree();
    // cr�ation du noeud sup�rieur
    racine = new DefaultMutableTreeNode("Poste de travail");
    // cr�ation d'un noeud pour chaque lecteur
    drive = File.listRoots();
    for (int i = 0 ; i < drive.length ; i++) {
    FSNode node = new FSNode(drive, drive[i]);
    addFolder(drive[i], node); // on descend dans l'arborescence du lecteur jusqu'� MAX_LEVEL
    racine.add(node);
    // Gestion d'evenement sur JTree (on �coute les evenements TreeExpansion)
    tree.addTreeExpansionListener(new TreeExpansionListener() {
    public void treeExpanded(TreeExpansionEvent e) {
    // lorsqu'un noeud est ouvert
    // on descend dans l'arborescence du noeud jusqu'� MAX_LEVEL
    TreePath path = e.getPath();
    FSNode node = (FSNode)path.getLastPathComponent();
    addFolder(node);
    ((DefaultTreeModel)tree.getModel()).reload(node); // on recharche uniquement le noeud
    public void treeCollapsed(TreeExpansionEvent e) {
    // lorsqu'un noeud est referm�
    //RIEN
    // alimentation du JTree
    DefaultTreeModel model = new DefaultTreeModel(racine);
    tree.setModel(model);
         setLayout(null);
    // ajout du JTree au formulaire
    tree.setBounds(0, 0, 240, 290);
    scrollpane = new JScrollPane(tree);
         add(scrollpane);
         scrollpane.setBounds(0, 0, 240, 290);
    * Recuperation des sous-elements d'un repertoire
    * @param driveOrDir
    * @param node
    public void addFolder(File driveOrDir, DefaultMutableTreeNode node) {
    setCursor(new Cursor(3)); // WAIT_CURSOR est DEPRECATED
    addFolder(driveOrDir, node, 0);
    setCursor(new Cursor(0)); // DEFAULT_CURSOR est DEPRECATED
    * Recuperation des sous-elements d'un repertoire
    * (avec niveau pour r�cursivit� et arr�t sur MAX_LEVEL)
    * @param driveOrDir File
    * @param node DefaultMutableTreeNode
    * @param level int
    private void addFolder(File driveOrDir, DefaultMutableTreeNode node, int level) {
    File[] fileList;
    fileList = driveOrDir.listFiles();
    if (fileList != null) {
    sortFiles(fileList); // on tri les elements
    // on ne cherche pas plus loin que le niveau maximal d�finit
    if (level > MAX_LEVEL - 1) {return;}
    // pour chaque �l�ment
    try {
    for (int i = 0; i < fileList.length; i++) {
    // en fonction du type d'�l�ment
    if (fileList[i].isDirectory()) {
    // si c'est un r�pertoire on cr�� un nouveau noeud
    FSNode dir = new FSNode(fileList[i].getName(), fileList[i]);
    node.add(dir);
    // on recherche les �l�ments (r�cursivit�)
    addFolder(fileList[i], dir, ++level);
    if (fileList[i].isFile()) {
    // si c'est un fichier on ajoute l'�l�ment au noeud
    node.add(new FSNode(fileList[i].getName(), fileList[i]));
    catch (NullPointerException e) {
    // rien
    * Recuperation des sous-elements d'un noeud
    * @param node
    public void addFolder(FSNode node) {
    setCursor(new Cursor(3)); // WAIT_CURSOR est DEPRECATED
    for (int i = 0 ; i < node.getChildCount() ; i++) {
    addFolder(((FSNode)node.getChildAt(i)).getFile(), (FSNode)node.getChildAt(i));
    setCursor(new Cursor(0)); // DEFAULT_CURSOR est DEPRECATED
    * Tri une liste de fichier
    * @param listFile
    public void sortFiles(File[] listFile) {
    triRapide(listFile, 0, listFile.length - 1);
    * QuickSort : Partition
    * @param listFile
    * @param deb
    * @param fin
    * @return
    private int partition(File[] listFile, int deb, int fin) {
    int compt = deb;
    File pivot = listFile[deb];
    int i = deb - 1;
    int j = fin + 1;
    while (true) {
    do {
    j--;
    } while (listFile[j].getName().compareToIgnoreCase(pivot.getName()) > 0);
    do {
    i++;
    } while (listFile[i].getName().compareToIgnoreCase(pivot.getName()) < 0);
    if (i < j) {
    echanger(listFile, i, j);
    } else {
    return j;
    * Tri rapide : quick sort
    * @param listFile
    * @param deb
    * @param fin
    private void triRapide(File[] listFile, int deb, int fin) {
    if (deb < fin) {
    int positionPivot = partition(listFile, deb, fin);
    triRapide(listFile, deb, positionPivot);
    triRapide(listFile, positionPivot + 1, fin);
    * QuickSort : echanger
    * @param listFile
    * @param posa
    * @param posb
    private void echanger(File[] listFile, int posa, int posb) {
    File tmpFile = listFile[posa];
    listFile[posa] = listFile[posb];
    listFile[posb] = tmpFile;

  • How do i get the path of the file selected for opening in JFileChooser

    hi
    I need to get the path of the file selected for opening or saving in the JFileChooser dialog box.Is there any method available.if not how do i get that?
    Thanks and Regards
    Saminathan.

    don't know if its the best/only way, but you could use the getSelectedFile() method in JFileChooser which returns a file and then use the getAbsolutePath() file method

  • How can I get the path of an existing file????

    Hi.
    I'm a newbie in Jsp development, so this question may appear trivial.
    How can I get the path into a String of an exixting file ..like ...
    String thepath = path_of("my file.txt");
    Thanks for your help.

    Try
    application.getRealPath("myFile.txt")

  • Getting the path of  a resource file inside the context

    I am trying to migrate some of our applications running on OracleApplicaiton Server. We have data resource xml file needs to use in the applicaiton. In Oracle Application server we used to give the actual path of the xml file to load the xml file to the parsers since we know the path of the directories after deploying the application as an ear file. How can I get the path of the files in weblogic after deployment. If this is not supported what is the alternative to get the relative path of that xml file to load in ? The xml file is in the root folder of the context.
    THanks
    Suneesh

    Hi Suneesh,
    Please try enabling the <show-archived-real-path-enabled> Tag to TRUE ...And then everything will work fine with the following code:
    context.getRealPath()
    At domain level in config.xml. For example:
    <web-app-container>
    <show-archived-real-path-enabled>true</show-archived-real-path-enabled>
    </web-app-container>
    *****OR *****
    At the web app level in weblogic.xml. For example:
    <container-descriptor>
    <show-archived-real-path-enabled>true</show-archived-real-path-enabled>
    </container-descriptor>
    For Archived Applications , It is always a best practice to use the getResourceAsStream() rather than using getResource().......Below code snippet should workout in 99% cases
    InputStream stream=this.getClass().getClassLoader().getResourceAsStream("someXMLorPropfile.properties");
    Thanks
    Jay SenSharma
    http://middlewaremagic.com/weblogic/?p=408  (Middleware Magic is Here)

  • Siebel 8.0.0.12 Fix Pack; Unable to get the seed from binary file.

    Hello Folks,
    Can anyone throw some light into what action is required on my scenario.
    I have applied Fix Pack Siebel 8.0.0.12 on top of 8.0.0.11 SBA. After it is appled, I am facing a documented issue within the Release Notes for the 8.0.0.12 Fix Pack
    The issue is "UNABLE TO LAUNCH URL AFTER APPLYING SIEBEL 8.0.0.12". I tried the steps given with the MR document, however, I am still having this issue.
    I am also not sure what is expected at the step of; Run the following command: seedgeneratorutil myseed.dat abcdef .
    It's asking me for a value to enter for seed at command prompt. "Enter the seed":
    what I should give here. As an assumption values,I gave SADMIN and tried to launch but still shows up the same error
    Please Assit
    Steps Details from Release Notes:
    UNABLE TO LAUNCH URL AFTER APPLYING SIEBEL 8.0.0.12
    Component: Server Infrastructure
    Subcomponent: SWSE
    Product Version: Siebel 8.0.0.12
    Base Bug ID: 11938270
    **Users are unable to launch the URL after applying the Siebel 8.0.0.12 Fix Pack.
    **Use the following workaround to address this issue:
    Navigate to the eappweb/bin directory from the command line on the SWSE installation.
    Run the following command:
    seedgeneratorutil myseed.dat abcdef
    NOTE: In the example, myseed.dat is a filename. You can give any file name you wish.
    The myseed.dat file is generated in the eappweb/bin directory.
    Edit eapps.cfg to include the following parameters under the SWE section:
    seedfile = < complete path for myseed.dat >
    Bounce the web server.
    (For Linux only) Copy libmod_swe.so from the eappweb/bin folder to the web/ohs/modules folder
    Thanks
    Kumar

    Wilson,
    Thanks for your reply.I have repeated the steps and regenerated the error messages.
    Browser
    Message:
    An error occurred while trying to process your request. This error indicates a problem with the configuration of this server and should be reported to the webmaster (along with any errors listed below). We apologize for the inconvenience
    Initialization error:
    Unable to get the seed from binary file.
    Log
    2021 2011-09-20 23:23:01 0000-00-00 00:00:00 +0530 00000000 001 003f 0001 09 ss110920_7068 7068 7852 E:\sba80\SWEApp\log\ss110920_7068.log 8.0.0.12 [20444] ENU
    ProcessPluginState     ProcessPluginStateError     1     000000024e781b9c:0     2011-09-20 23:23:01     7852: [SWSE] Unable to get the seed from binary file.
    Eapps.cfg
    [swe]
    Language = enu
    Log = errors
    LogDirectory = $(SWSERoot)\log
    ClientRootDir = $(SWSERoot)
    SessionMonitor = False
    AllowStats = true
    LogSegmentSize = 0
    LogMaxSegments = 0
    DisableNagle = False
    seedfile = E:\sba80\SWEApp\BIN\80012seed.dat
    Thanks
    Kumar

  • 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.

  • How to get the URI of a file in a WAR

    Hi all,
    I have a deployed WAR.
    One of its files need to get the URI of another file in this war.
    In exploded format, application.getRealPath(thefilename) would do the
    trick. But it failed if the application is deployed in WAR archive.
    What's the workaround ?
    Note that I need the full path of the file since I need to read its
    content and parse it as XML using DOMParser that requires the full URI ..
    Any help appreciated ..
    mona

    I have a piece of code that does this that looks like this:
    InputStream inStream =
    <ServletClassName>.class.getResourceAsStream("/foo.xml");
    InputStreamReader inReader = new InputStreamReader(inStream);
    And 'foo.xml' is put in the classpath either by placing it in a .jar file in
    the WEB-INF/lib directory or by placing it in a .jar file that is deployed
    with the webapp .war file in an .ear file and then referenced by the
    'Class-Path:' manifest directive in the META-INF/MANIFEST.MF file of the
    webapp.war file. Both ways work. I would think you could put 'foo.xml' in the
    WEB-INF/classes directory and that work work, too. But, I haven't tried that.
    Bill
    Mona Ramlawi wrote:
    Hi all,
    I have a deployed WAR.
    One of its files need to get the URI of another file in this war.
    In exploded format, application.getRealPath(thefilename) would do the
    trick. But it failed if the application is deployed in WAR archive.
    What's the workaround ?
    Note that I need the full path of the file since I need to read its
    content and parse it as XML using DOMParser that requires the full URI ..
    Any help appreciated ..
    mona

  • How to get the path of the image stored in DMS

    Hi everyone..
    My question is that I have attached an image with an order through transaction jha2n..
    Now my requirement is to get the image in report..
    I know the Logical id in ISM_l_ord class and physical id in ISM_P_Ord class.
    I know that link between image and order is in SKWG_BREL.
    But i am not able to get the path so that i can show the image in docking control.
    pls help to retrive the path of the image stored...
    Thanks
    Pooja

    EpicMaster wrote:Now the problem is when I run the application through the .jar file in the dist/ directory the images simply wont load...
    ..lblProduct.setIcon(new ImageIcon("Resources.zip/res/Product.png"));
    Now the problem is when I Build&Clean the whole project which creates a /dist directory containing the complied and execulatble .Jar file for the application AND a folder called "lib" which contains the Resource.Zip folderThe String based constructor to ImageIcon presumes the String represents a File path. File objects do not work with resources inside Jar or Zip archives, for those, you need an URL. Gain the URL using something like..
    URL urlToImage = this.getClass().getResource("/res/Product.png");

  • How to get the path of the selected Jtree node for deletion purpose

    I had one Jtree which show the file structure of the system now i want to get the functionality like when i right click on the node , it should be delete and the file also deleted from my system, for that how can i get the path of that component
    i had used
    TreePath path = tree.getPathForLocation(loc.x, loc.y);
    but it gives the array of objects as (from sop)=> [My Computer, C:\, C:\ANT_HOME, C:\ANT_HOME\lib, C:\ANT_HOME\lib\ant-1.7.0.pom.md5]
    i want its last path element how can i get it ?

    Call getLastSelectedPathComponent() on the tree.

Maybe you are looking for

  • Error while exporting BO Report to excel

    Post Author: noble CA Forum: .NET When ever i try to export a Big BO 6.5 Report to (Almpst 8000 Pages ) to Excel 2003 I am getting BO Unhandiled exception. Anybody can advice how to solve this issue.

  • Is there a way to Extract all formulas from Crystal Reports files?

    Hi: I have about 40 Crystal Reports (.rpt files).  I need to go through each one and look at formulas if a certain variable/value is used since it has currently changed.  It is taking way too long and not to mention inefficent to open each file, look

  • How to refer a field in a header as a variable

    Hi, Question: Report header has student id display using <?STUDENT_ID?>, how can I refer this field as a variable in the body section to do some if statement? have tried to use the folllowing fashion in the header <?variable@incontext:v_id;STUDENT_ID

  • Music iphone to computer

    I recently got a new pc...how can i import my songs from my iphone to pc? I can see the music on the device in itune but i cant play them or save them! Can someone please help an iphone newbie... thanks in advance

  • Satellite P855-10G runs out of battery even when turned off

    Hi everyone, I have bought the Toshiba Satellite P855-10G, but im terrified because he runs out of battery even when turned off.. Anyone knows how can i solve the issue? Best regards, Igor Tarelho