How to create the right path depending from Os

Hi all,
I should do a simple thing
1. Get a dir by a filechooser
2. Get a dir by another filechooser
3. Extract all files' name by 1.
4. Append every filename from 3. to 2.
5. 4.toString()
I have problem in 4. Becouse if I append them as Strings I've to add a separator character between dir an filename. This char id \ under Windows and / under linux. Is here any way to concatate a filename and a dir indipendently from filesystem?
This is the current version that work only on Windows:
            final JFileChooser fc = new JFileChooser();
            fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            fc.setDialogTitle("Select Source Folder");
            returnVal = fc.showOpenDialog(this);
            File file = fc.getSelectedFile();
            final JFileChooser fc2 = new JFileChooser();
            fc2.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            fc2.setDialogTitle("Select Destination Folder");
            returnVal2 = fc2.showOpenDialog(this);
            File file2 = fc2.getSelectedFile();
            if (returnVal2 == JFileChooser.APPROVE_OPTION &&
                returnVal == JFileChooser.APPROVE_OPTION) {
                File allFiles[] = file.listFiles();
                for (int i = 0; i < allFiles.length; i++) {
                    if (allFiles.isFile()) {
Mp3s mp3file = new Mp3s(allFiles[i].getAbsolutePath().
toString(),
file2.getAbsolutePath().
toString() +
"\\" + allFiles[i].getName());
Mp3 is a class that gets 2 strings (1st_path/filename, 2nd_path/filename)
or (1st_path\filename, 2nd_path\filename) depending from OS and that's the dial
Hope everithing is clear.
Tnx in advance
Ciro

The forward slash should be used, regardless of the platform. The only time this may not work under Windows is if you actually pass the string outside of the Java process. But things like:
File x = new File("/some/directory/somefile.ext");
should work under all OS environments. Under Windows, the above will reference whatever the current drive is (C:, for example), so it would resolve to c:\some\directory\somefile.ext when all is said and done. Java takes care of the conversion for you.

Similar Messages

  • How to input the right path that i need in miscellaneous files folder

    i have this sample code
    public class image extends JFrame
    private JLabel statusBar = new JLabel();
    private JMenuItem menuFileExit = new JMenuItem();
    private JMenu menuFile = new JMenu();
    private JMenuBar menuBar = new JMenuBar();
    private ImageIcon imagedoc = new ImageIcon(button.class.getResource("help.gif"));
    private JButton buttondoc = new JButton();
    private JPanel jPanel1 = new JPanel();
    it works but i used the pictures in the file that is already with the jframe.
    i want to add other image, i've already add them on my project but my problem is it is located to another folder. the miscelleanous files folder. if i used the same code, there are errors.
    i want to know the right path in how i can use those images in that folder.
    thanks in advance
    pls reply as soon as possible... i really need this one.

    Hello,
    I think the way to make your images/icons work in your jclient app,
    is to use such a code (test it):
    Class c = Class.forName("YourList.YourListWindowFrame");
    java.net.URL testt = c.getResource("create.gif");
    ImageIcon imageCreate = new ImageIcon(testt);
    if ( imageCreate != null)
    buttonCreate.setIcon(imageCreate);
    But this only works if you copy your icon (create.gif ) into your class directory
    YourList/classes/YourList. This is if your output directory in your project Settings
    is set to YourList/classes and the package is YourList.
    Even if your additional class path is set to YourList/classes and you try to set
    your additional class path to YourList/icons, your icons are not found.
    It looks like JDeveloper is only looking in your output sub directories.
    When you build your application, your gif files are "copied" to your output directory:
    YourList/classes.
    So, you will have to manually put the icons in your class/packages to make this work.
    The idea is that the image files need to be in the same dir as the Java
    class file that loads them. Therefore, the best way to do that is to have
    an ImageLoader class that is in the same folder as the images one:
    public class ImageLoader
    public ImageLoader()
    public ImageIcon getImageIcon(String name)
    return new ImageIcon(getClass().getResource(name + ".gif"));
    and would be called like this:
    mButtonButton.setIcon(imgl.getImageIcon("JButton"));
    http://otn.oracle.com/sample_code/products/jdev/jclient/jclient_binding_demo.html
    There you will find a jClient Component Demo that has this code you can use.
    (its a pretty cool and extensive demo ... he can look at files ImageLoader.java
    and StartFrame.java to see how that particular coding is done.)
    Reference:
    I don't how much help that can be for you, but here is an interesting Metalink note :
    Note 130302.1
    "Sample JSP Code: Directory and File Browser Implemented with Custom Tag Library"
    Regards,
    Steff

  • How to get the pull path name from a file upload window

    Hello everyone!
    I have encountered the following problem with the following JSP code:
    <form method="post" action="filename.jsp">
    Upload JAVA program:
    <input type=file size=20 name="fname" accept="java">
    <input type=submit value="go">
    </form>
    <%
    String s = "";
    if (request.getParameter("fname") != null)
    s = request.getParameter("fname")
    %>
    The value of s is alway the filename. However I want to get the full path in addition to the filename, so that I can read the file. Does anyone know how to get the pull name of the file?
    thanks a lot in advance,

    Dear Sir,
    thanks a lot for your reply. Please let me explain what I intended to do: I want to upload a file from the local machine and then read the content of the file. Therefore I need to the fullpath of the filename like /var/local/file.java instead of file.java. The latter is what I got.
    The problem I have with your code is that the function like "request.getServerScheme()" is not recognized. Maybe is it because I didn't install servelet package? I only installed javax package btw. Also my application runns on Tomcat server if this could give you some information. The error message I had is as follows:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 36 in the jsp file: /addExercise.jsp
    Generated servlet error:
    [javac] Compiling 1 source file
    /usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:133: cannot resolve symbol
    symbol : method getServerScheme ()
    location: interface javax.servlet.http.HttpServletRequest
    url = request.getServerScheme()
    ^
    An error occurred at line: 36 in the jsp file: /addExercise.jsp
    Generated servlet error:
    /usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:136: cannot resolve symbol
    symbol : method getServerScheme ()
    location: interface javax.servlet.http.HttpServletRequest
    + ((("http".equals(request.getServerScheme()) && request.getServerPort() != 80)
    ^
    An error occurred at line: 36 in the jsp file: /addExercise.jsp
    Generated servlet error:
    /usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:137: cannot resolve symbol
    symbol : method getServerScheme ()
    location: interface javax.servlet.http.HttpServletRequest
    ||("https".equals(request.getServerScheme()) && request.getServerPort() != 443))
    ^
    An error occurred at line: 36 in the jsp file: /addExercise.jsp
    Generated servlet error:
    /usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:139: cannot resolve symbol
    symbol : method getServletConfig ()
    location: interface javax.servlet.http.HttpServletRequest
    + "/" + request.getServletConfig().getServletName()
    ^
    An error occurred at line: 36 in the jsp file: /addExercise.jsp
    Generated servlet error:
    /usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:140: cannot resolve symbol
    symbol : variable path
    location: class org.apache.jsp.addExercise_jsp
    + "/" + path
    ^
    5 errors
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:128)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
         org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:413)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:453)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:437)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:555)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

  • Address (how to create the right string)

    I have to pass to a JFileChooser a patch of a server directory.
    the client recive from the server the string... (example C:\ )
    now i can have the socket address with socket.getInetAddress();
    now i would like to create with those string a tring that is the right address for the server.
    Many thanks

    You can't access sockets with a JFileChooser. It is a component to see files and not IP connections
    If you need to access a directory in your server using a JFileChooser in your client, you should use something like:
    //name_of_the_server_machine/shared_directory (if you are under windows, or in linux if you can use samba or nfs)

  • How to create the integration with webmethods from portals

    Hi Experts,
    I got a requirement to integrate the webmethods system from my portal server.....
    If anybody have documents kindly circulate the same to [email protected]
    Higher points will be rewarded for the each useful inputs....
    Thanks In Advance,
    Jasmine

    HI jasmine,
    For integrating webmethods you can use application integrator iViews.
    For Step-By-Step Guide to implement Application Integrator
    refre this weblog.
    Re: Integration with Java applications
    And for Integrating your Web Front-ends into the SAP Enterprise Portal using the Application Integrator
    refre this weblog
    Integrating your Web Front-ends into the SAP Enterprise Portal using the Application Integrator
    And for refrence use this link.
    http://help.sap.com/saphelp_nw2004s/helpdata/en/70/5a3842134bad04e10000000a1550b0/frameset.htm
    PS: If helpful award points
    --Deepak.

  • How to find the right primary key for DSO from Business Content

    According to best practice design, it is reccomended to make a  DSO where all fields from Business COntent Datasources are transferred.
    But, how to find the right primary indeks ?
    Any good suggestions ?
    For many of the Business Content dataflows there are not DSOs present, so ther e is no tip to get from the dokumentations as gfar as I have found.
    best Regards
    Ingrid

    Hi Ingrid,
    Your question will be perfect in case if you are going for a Custom cube.
    You will not have any problem when you create a Datasource in R/3 level even if it is been built on a single table or on view.
    Only point that you want to know how to design my Key fields in ODS.
    This will be purely depends at what level that you want to bring the data.
    Egg:-
    If you run the data source in RSA3 and check for Each GL if you have 10 liine items and you want all the 10 line items to be transfered to BW.
    In this case you need to check what is the unique combination of fields that is making this lineitems to exists as 10.then include all those fields into Your ODS Key Fields.
    This way you can have 10 records for that perticular GL in both sides, by which u will make sure that the data is been completely transfered.
    If in case if you clude your own Key fields then you will get the correct Total in report for each GL but you can't see all those 10 line items.
    For any case you need to figureout how many records that you want to take into BW based on that check the fields that makes it unique and then add them to ODS Keyfields that will solve your requirement.
    I think this will clear your doubt.
    Best Regards,
    VNK.

  • How to get the absolute path of a file from the local disk given the file n

    how to get the absolute path of a file from the local disk given the file name

    // will look for the file at the current working directory
    // this is wherever you start the Java application (cound be C: and your
    // application is located in C:/myapp, but the working dir is C:/
    File file = new File("README.txt"); 
    if (file != null && file.exists())
        String absolutePath = file.getAbsolutePath();

  • How to create the change document functionality for a dependent objects?

    May I please know how to create the change document functionality for a dependent objects?
    I have done it follow the same process as for business process objects. But when i try to test it in BOBT, there is no records under "FIELD_CHANGE_WITH_FILTER". It seems the change hasn't been recorded.
    If the way I did to create change document for dependent object is correct, please also kindly advise the possibilities for why there is no record during testing.
    thanks in advance.

    I also have some doubts about the business object.In this case,one abstract BO hase a subnode wihich is root extended.I added the change document for this node under the category "root_extended" and then tested the function in BOBT.I got some error message "can't find the root key".Shall i redefine the method /BOFU/IF_CDO_CREATION~IS_CDO_CREATION_ACTIVE so as to solve the problem?
    Thx.

  • When importing from my camera or file in Lightroom 5 my pictures are over-exposed by 1-2 stops, while they are well exposed on the camera-screen. How to get the 'right-exposed pictures on the screen?

    When importing from my camera or file in Lightroom 5 my pictures are over-exposed by 1-2 stops, while they are well exposed on the camera-screen. How to get the 'right-exposed pictures on the screen?

    There is an option in your Lightroom preferences on the General tab, "Treat JPEG files next to raw files as separate images". If you have that option checked then Lightroom will import and display both your raw and JPEG files. Are you using active D-lighting on your camera? If you are then you need to turn off that feature.

  • How to create the verify.der file in portal ? valid to and valid from

    hi Experts,
    am facing the problem in SAP logon method without user mapping but it's having a problem, The problem is  create the Transaction iview it's not there . Back end server is not response how to create the Valid TO and Valid From in portal.
    Thanks & Regards
    Chandu

    Chandu,
           1.      Start the SAP J2EE Engine Visual Administrator: C:\usr\sap\<SID>\JC00\j2ee\admin\go.bat.
           2.      Navigate in the left tree panel to Cluster -Server -Services -Key Storage - Runtime  TicketKeystore - SAPLogonTicketKeypair u2013cert.
    Here you can go ahead and create a new ticket.
    Hope that helps.
    Cheers,
    Sandeep Tudumu

  • How to change the library path from development machine to application serv

    hi
    how can i change the library path which i developed in windows machine and the library path is c:/fas/dss.pll and now i hosted all forms,menu,library and reports in application server that is running in linux machine now i want to know how to change the library path c:\fas\dss.pll to /oracle/fas/dss.pll.

    Hi !
    It is standard functionality to change ship-to party address in ISA B2C. This happens only from the checkout.inc.jsp. The ship-to party is part of the basket object.
    Cheers,
    Ashok.

  • How to create the logical file name

    Hi All,
        I have requirement where i need to post the Inventory Management data. for this i need to execute std. program RM07MMBL which is having logical file name in the selection screen. but i have placed my input file in application server.
       Can any one tell how to create the Logical filename which refers the physical path. I also tried <b>t-code SF01 & Table - FILENAMEC</b>I and found that we need to add an entry in this table but i really dont know how we have to do since this table cannot be maintained in SM30 also..
      Help Me.
      Thanks in Advance!...
    Regards,
    Ramkumar

    Hi Ram,
    Try using FILE transaction code...
    Follow these steps to create:::
    Double click on Logical file Path Definition
    Click on New Entries,
    Give Logical file Path name as Z_LOGICAL PATH and save it
    now choose this path and double click on Assignemt of Physical path to Logical path
    double click on the OS name
    Give some description and give some Physical path name from AL11 transaction and save it
    Now Double click on Logical File Name Definition,
    Click on New Entries,
    Give some logical file name: Z_LOGICAL_FILENAME
    Physical file: test
    Data Format: BIN
    Logical Path: Z_LOGICAL PATH
    Hope this helps
    Regards,
    Phani
    Message was edited by:
            Sivapuram Phani Kumar

  • How to create the relationship between ESSBASE 11 and DM in OBIEE11

    Hi Experts,
    I have one requirement that there is one property table named 'Store Master' in DW,and it contains a lot of attribute, such as Open Date, Close Date, IS 24 Hour etc.
    But another data source is essbase and based on this source, I create all reports.
    In ESSBASE, it has one dimension and hierarchy Location, and it has four level, Country(L1),Region (L2),Province(L3),Store(L4)
    So I want to know how to create the relationship between Location (ESSBASE) and Store Master (DM).
    I try to create one relationship in physical layer between Gen4,Location and Store, then drag the open date and close date into Location Dimension in BMM,then Presentation Layer.
    When I drag column 'Open Date' ,'Gen4,Location ' and 'Sales' into reports, it will generate the following error message:
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 43119] Query Failed: [nQSError: 14020] None of the fact tables are compatible with the query request Dim Region.Store Open Date. (HY000)
    However, when I remove the column 'Open Date'. it will be ok.
    So what I missing the steps? Please help me. Thanks.

    >
    '2. Now, pull the 'Store' column from relational DB onto the Gen5, Location column from Essbase. This action now creates, two logical sources for your 'Store' column.'
    If the length from different data source is not same,such as 1001(DM),L_1001(ESSBASE), can I drag the 'Store' column from relational DB onto the Gen5, Location column from Essbase?
    I think it does not work.Right?Hi,
    I am not sure if you are talking about the length(as in varchar(128)) of the member value being different in different sources, or the member itself is different in both the sources.
    I am still assuming, that you are referring to the members not same in both the sources.If it is, the whole concept of federation is based on conforming dimensions. So, it needs that the same dimension information is present in both the sources and then only, you know we can analyze the numbers based on this dimension. So, either the dimension being different in both sources, or the members not present in both the dimensions might lead to incorrect numbers.
    So I select Store Attributes in relation DB and Location in ESSBASE in physical layer, then create the physical join, such as right("Hour Sales"."H_Sales".""."H_Sales"."Gen6,Location",4) = "Authorization".""."EDW"."T_EDW_MDM_STORE"."US_CODE", then drag the OPEN_DATE and CLOSE_DATE in relation DB to Location in ESSBASE in BMM,finially drag them into presentation layer.We create physical layer relationships, to send over the same relation to the underlying database during querying. So, creating a physical relationship between essbase cube and relation database would not help here.
    When you set up this federation, BI Server sends individual queries to each source and maps the conforming dimension members internally.
    Hope I was clear, and this helps.
    Thank you,
    Dhar

  • How to create the relationship between ESSBASE 11 and DM  in OBIEE 11G?

    Hi Experts,
    I have one requirement that there is one property table named 'Store Master' in DW,and it contains a lot of attribute, such as Open Date, Close Date, IS 24 Hour etc.
    But another data source is essbase and based on this source, I create all reports.
    In ESSBASE, it has one dimension and hierarchy Location, and it has four level, Country(L1),Region (L2),Province(L3),Store(L4)
    So I want to know how to create the relationship between Location (ESSBASE) and Store Master (DM).
    I try to create one relationship in physical layer between Gen4,Location and Store, then drag the open date and close date into Location Dimension in BMM,then Presentation Layer.
    When I drag column 'Open Date' ,'Gen4,Location ' and 'Sales' into reports, it will generate the following error message:
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 43119] Query Failed: [nQSError: 14020] None of the fact tables are compatible with the query request Dim Region.Store Open Date. (HY000)
    However, when I remove the column 'Open Date'. it will be ok
    So what I missing the steps? Please help me. Thanks.

    >
    '2. Now, pull the 'Store' column from relational DB onto the Gen5, Location column from Essbase. This action now creates, two logical sources for your 'Store' column.'
    If the length from different data source is not same,such as 1001(DM),L_1001(ESSBASE), can I drag the 'Store' column from relational DB onto the Gen5, Location column from Essbase?
    I think it does not work.Right?Hi,
    I am not sure if you are talking about the length(as in varchar(128)) of the member value being different in different sources, or the member itself is different in both the sources.
    I am still assuming, that you are referring to the members not same in both the sources.If it is, the whole concept of federation is based on conforming dimensions. So, it needs that the same dimension information is present in both the sources and then only, you know we can analyze the numbers based on this dimension. So, either the dimension being different in both sources, or the members not present in both the dimensions might lead to incorrect numbers.
    So I select Store Attributes in relation DB and Location in ESSBASE in physical layer, then create the physical join, such as right("Hour Sales"."H_Sales".""."H_Sales"."Gen6,Location",4) = "Authorization".""."EDW"."T_EDW_MDM_STORE"."US_CODE", then drag the OPEN_DATE and CLOSE_DATE in relation DB to Location in ESSBASE in BMM,finially drag them into presentation layer.We create physical layer relationships, to send over the same relation to the underlying database during querying. So, creating a physical relationship between essbase cube and relation database would not help here.
    When you set up this federation, BI Server sends individual queries to each source and maps the conforming dimension members internally.
    Hope I was clear, and this helps.
    Thank you,
    Dhar

  • How to give the file path in adf application

    Hii all,
    I want to use castor xml framework in adf application..
    for which i have to un- marshaller the xml file..
    by using following method-
    Person person = (Person)
    Unmarshaller.unmarshal(Person.class,
    new FileReader("src/com/person.xml"));
    if i use this method in a java class inside a main method directly it works fine,
    but when i try to initiate the java class through a jspx page deployed on integrated server..
    it gives the file not found exception..
    how to define the file path so it can be properly used even when application is deployed on server.
    Thanks

    duplicate {thread:id=2418158} ?
    I guess the path you are using is wrong. It works on your mashiene as the src path is available. When you run the app on a server (jspx file) there is no src path as long as you don't include it in your WAR wich you should not do anyway.
    If you need to access such data you can create a folder in your webroot folder and the the resources from there as /xml_folder_name or if the xml files shouldn't be visible from the outside put the folder under hte web-inf folder.
    Timo
    Edited by: Timo Hahn on 23.07.2012 16:20

Maybe you are looking for

  • RFC APPLICAITON ERROR

    Hi All, I am debugging a scenario which inculde RFC as recevier and SOAP as sender communicaiton channel. Though at design time my Message mapping and Interface Mapping test was successfull and getting RFC_ADAPTER APLLICATION ERROR in moni at Request

  • Just installed 10g: Main form cannot find subforms or menus

    I just added 10g FOrms Builder to my PC. I was running 9i and it still exists on the machine. Problem: My main form, when run locally from Forms Builder cannot find any of its menus or subforms unless the FULL PATHs are defined in the properties or C

  • Help in resizing photo for masthead

    I am trying to resize a photo from 3264 x 2448 to 600 x 149 and I just can't seem to do it. I'd appreciate a how to...need it for masthead. Thanks, Toni

  • Class field initialization outside class constructor

    Hi, what are the benefits of initializing a class field outside the class constructor? I use this for fields, that i do not need to pass parameter to via the constructor. The code seems more clear/easy to read.

  • Photoshop CS5 Help! T.T?

    hi guys! I'm a total newbie on this so maybe this problem is really simple.. but I hope you can help me! When I open a picture in PS CS5, it automatically turns into a yellow-like gradient. IDK. It's always like this... I tried looking for the proble