Java.io.File

Hello i created a class that extends java.io.File
public Class MyClass extends File
After i created instances of MyClass to populate a tree, i want to put a label ans icons for it and i proceed this way:
public String getText(Object element) {
          if(element instanceof MyClass) {
               return ((MyClass)element).getName();
          } else {
               System.out.println("element is not an instance of MyClass");
               return ((File)element).getName();
     }Someone can tell why it is not an instance of my class?

So is there somebody to help me please....
I got the root of my tree like this Session.getRoot()
Here is the code for Session
public class Session {
     private static MyClass logesco;
     public static final String PATH = System.getProperty("user.home") + File.separator;
     public Session() {
          super();
          logesco = new MyClass(PATH, "logesco");
          if(!logesco.exists() && !logesco.isDirectory()) {
               boolean success = logesco.mkdir();
               if(success) System.out.println("Fichier cr�� avec succ�");
               else System.out.println("Le fichier n'as pas �t� cr��");
          }else
               System.out.println("Le fichier existe d�ja");
     public static MyClass getRoot() {
          if(logesco == null) {
               System.out.println("null");
               logesco = new MyClass(PATH, "logesco");
               if(!logesco.exists() && !logesco.isDirectory()) {
                    boolean success = logesco.mkdir();
                    if(success) System.out.println("Fichier cr�� avec succ�");
                    else System.out.println("Le fichier n'as pas �t� cr��");
               }else
                    System.out.println("Le fichier existe d�ja");
          } else {
               System.out.println("non null");
               return logesco;
          return null;
     }and the code from MyClass class that extends java.io.File
public class MyClass extends File {
     private String theme;
     private String description;
     private String type;
     public MyClass(String arg0) {
          super(arg0);
          // TODO Auto-generated constructor stub
     public MyClass(String arg0, String arg1) {
          super(arg0, arg1);
          // TODO Auto-generated constructor stub
     public MyClass(File arg0, String arg1) {
          super(arg0, arg1);
          // TODO Auto-generated constructor stub
     public MyClass(URI arg0) {
          super(arg0);
          // TODO Auto-generated constructor stub
     public MyClass(String aPath, String aName, String aTheme) {
          super(aPath, aName);
          this.theme = aTheme;
     public MyClass(String aPath, String aName,
               String aTheme, String aDescription) {
          this(aPath, aName, aTheme);
          this.description = aDescription;
     public MyClass(LogescoProject parent, String aName,
               String aTheme, String aDescription) {
          this(parent, aName);
          this.theme = aTheme;
          this.description = aDescription;
     public String getTheme() {
          return this.theme;
     public String getDescription() {
          return this.description;
     public void setTheme(String aTheme) {
          this.theme = aTheme;
     public void setDescription(String aDescription) {
          this.description = aDescription;
     public void addProject(MyClass aProject) {
          // TODO Auto-generated method stub
          ArrayList<LogescoProject> projects = new ArrayList<MyClass>();
          projects.add(aProject);
     public boolean isProject() {
          return true;
     public MyClass createProject() {
          this.setTheme(theme);
          this.setDescription(description);
          if(!this.exists() && !this.isDirectory()) {
               boolean success = this.mkdir();
               if(success) System.out.println("Fichier cr�� avec succ�");
               else System.out.println("Le fichier n'as pas �t� cr��");
          }else
               System.out.println("Le fichier existe d�ja");
          return this;
     public void createProject(MyClass newProject) {
          newProject.setTheme(theme);
          newProject.setDescription(description);
          if(!newProject.exists() && !newProject.isDirectory()) {
               boolean success = newProject.mkdir();
               if(success) System.out.println("Fichier cr�� avec succ�");
               else System.out.println("Le fichier n'as pas �t� cr��");
          }else
               System.out.println("Le fichier existe d�ja");
     public String getType() {
          return this.type;
}

Similar Messages

  • Java.io.File not found in JDK 1.4

    why the java.io.file is deprecated.
    Frans

    [fthamura],
    why the java.io.file is deprecated.Probably because in J2SE 1.4, the New I/O package java.nio package provides scalable I/O operations for files. Through the File channels, a programmer will be able to provide memory-mapped buffers, improved file locking mechanism and faster I/O transfers with the new API package.
    FransHTH.
    Allen Lai
    Developer Technical Support
    SUN Microsystems
    http://www.sun.com/developers/support/

  • Getting all the members (variables, methods AND method bodies) of a java source file

    For a project I want to programmatically get access to the members of java source file (member variables, methods etc) as well as to the source code of those members. My question is what is the best method for this? So far I have found the following methods:
    Use AST's provided by the Java Source API and Java Tree API, as discussed in the following posts:
    http://today.java.net/pub/a/today/2008/04/10/source-code-analysis-using-java-6-compiler-apis.html
    http://weblogs.java.net/blog/timboudreau/archive/2008/02/see_java_code_t.html
    http://netbeans.dzone.com/announcements/new-class-visualization-module
    This has the disadvantage that the classes actually have to be compilable. When I look at the Netbeans Navigator view however, it provides me with a nicely formatted UI list, regardless of the "compilable" state of the class.
    Thus I started looking at how to do this... The answer appears to be through the use of tools such as JavaCC: https://javacc.dev.java.net/
    ANTLR: http://www.antlr.org/
    which are lexers and parsers of source code. However, since the Navigator panel already does this, couldn't I use part of this code to get me the list of variables and methods in a source file? Does the Navigator API help in this regard?
    Another route seems to be through tools such as
    BeautyJ: http://beautyj.berlios.de/
    which run on top of JavaCC if I am correct, and which has the ability to provide a clean view on your java code (or an XML view). However, BeautyJ does not seem to be too actively developed, and is only j2se1.4 compatible.
    I hope someone can shed a light on the best way to go about what I want to achieve. Somebody already doing this?
    (I crossposted on the Netbeans forums too, hope this is OK...)

    I'm currently developing a LaTeX editor(MDI) and I do the same thing, but I don't know what exactly do you need.

  • How to read the java class file to convert it in java.

    hello all,
    i m developing the java application which generated the java code from the java 'class file' .
    Can anybody please help me, Is any java support for reading the class file? or how to know the class file format?
    I know the application javad, jad, javap which is doing the same thing.
    thanks for reply,
    - Jayd

    do you mean decompiling? there are tons of java decompilers available out there, what exactly are you trying to do here?

  • How to convert a .jsp to a .java/.class file for use in peoplesoft

    Hi java/jsp experts,
    I want to convert a .jsp to a .java/.class file. is there a tool available, please let me know if you have any pointers....
    or can i do it manually:
    these are a few lines that the .jsp contains, and i would like to translate this to be in .java/.class format:
    <%@ page import="sun.misc.BASE64Encoder, javax.crypto., javax.crypto.spec."%>
    <%@ page import="java.util.StringTokenizer" %>
    <%@ page import="java.util.Map" %>
    <%!
    sb.append("<input type=\"hidden\" name=\"orderPage_serialNumber\" value=\"");
    sb.append(serialNumber);
    sb.append("\">\n");
    return sb.toString();
    %>
    how can i translate the above import statements and html elements from jsp to java, please let me know.
    Once i have the .java file created from the .jsp, I will compile .java to create the .class file and invoke the .class in peoplecode by using java apis available in peopletools.
    Thanks in advance.

    Is there a way convert a binary .exe file( compiled by
    another compiler) into Java .class/.jar file ? Anyone
    know of a free program that can do this?It's not possible. There are many decompilers and disassemblers for Java but nothing will take you from ANY binary to Java source. It would be the end of computing as we know it and the beginning of a new era -:)

  • How to convert dll to a java class file?

    Hi folks:
    I have some DLLs in VB and C++ and I wanna to convert them to a java class file. Does anybody know if exist a sw or easy way to do it?
    thanks
    Autair

    Well, I believe you could write JNI to call the functions in the DLLs, although I wouldn't recommend it. (You'd have a non-portable, fragile result.)

  • How to convert java .class file to .dll file

    hi,
    I got a problem, I have to convert my java .class file to .dll file. Microsoft VC++ program will invoke the converted .dll file.
    Is there any other possibility.
    I was confused.
    Cam any body help me. If you are having solution for the can you send to my [email protected] account.
    thanks,

    No, it is not possible to do what you are suggesting. Yes, you could produce a DLL that wraps the JVM and loads your java class exposing a C and/or C++ callable interface, but that is a lot to go through unless your class is VERY complex. Otherwise, you might want to just create and maintain two implementations.

  • How can I share a *.java source file across multiple projects in NetBeans?

    I'm sure this simple and a pretty common operation but how can I share a *.java source file across multiple projects in NetBeans? Right now I keep cut, coping and pasting the same source file between multiple projects to re-use the same code. But I could I make this source file a library file or something like that so that I could access it from any project. I assume this would be a generic operation but I mentioned NetBeans for clarity. Thanks.

    fiebigc wrote:
    I know I mentioned NetBeans but I'm most interested in the generic method for creating a library of source files that I can call into whatever program I am developing. I've done such a thing in C using header files and such but I'm trying to get a direction on how this is accomplished in Java. I'm sorry if I could edit the title I would. If anyone wants to be specific about NetBeans I welcome that too.
    Edited by: fiebigc on Jun 20, 2008 5:57 PM
    >I know I mentioned NetBeans but I'm most interested in the generic method for creating a library of source files that I can call into whatever program I am developing. I've done such a thing in C using header files and such but I'm trying to get a direction on how this is accomplished in Java. I'm sorry if I could edit the title I would. If anyone wants to be specific about NetBeans I welcome that too.
    Edited by: fiebigc on Jun 20, 2008 5:57 PM
    Create a class library.
    Write your code, compile it to .class files, put those class files in a .jar file and include the jar file in the classpath whenever you want to compile a project against it.

  • How can i run a java class file from shell?

    Hi all,
    I've a .class file named "File" that contains Main method, it is in the package "File2".
    How can I run it by shell command?
    PS: "java -cp . file" doesn't work it launch->
    Exception in thread "main" java.lang.NoClassDefFoundError: File2/File (wrong name: File2/File)
    Thanks in advance.

    Just to understand: is File2 ar jar archive or not? If it is a jar archive, have you tried open File2.jar? If File2 is a directory within the current directory, have you tried java -cp . File2/File? I just tested with a set of classes and it works... Let me be precise:
    * Let us imagine you are working in a directory whole path is PathToDir/
    * in this directory you have the classes put in a directory called File2
    * in order to launch File.class then you would have to invoke :
    cd PathToDir/ (just to be sure)
    java -cp . File2/File
    *if you were to do the following then you would have the problem you describe
    cd PathToDir/File2/
    java -cp . File

  • Static lookup lists:read data from a Java *.properties file

    Hi
    i need to make static lookup lists i am using read data from a Java *.properties file
    i am using the Class "PropertyFileBasedLookupViewObjectImpl" that wrote by Steve Muench in ToyStore.
    but i need to use the default language for that i update the loadDataFromPropertiesFile()
    method to find the correct properties file
    String temp=Locale.getDefault().getLanguage();
    String propertyFile =
    getViewDef().getFullName().replace('.', '/')+"_"+temp+ ".properties";
    the problem:
    For English(TEST_en.properties) it is good and working
    For Arabic(TEST_ar.properties) read from correct file _ar.properties
    but the dispaly character is wrong
    When Debug
    In the File 1=&#1583;&#1605;&#1588;&#1602;
    In debug 1=/u32423

    Depending on your use case you can either use a programmatic VO or directly expose the JV class as a data control.
    http://docs.oracle.com/cd/E18941_01/tutorials/jdtut_11r2_36/jdtut_11r2_36.html

  • How to access variables declared in java class file from jsp

    i have a java package which reads values from property file. i have imported the package.classname in jsp file and also i have created an object for the class file like
    classname object=new classname();
    now iam able to access only the methods defined in the class but not the variables. i have defined connection properties in class file.
    in jsp i need to use
    statement=con.createstatement(); but it shows variable not declared.
    con is declared in java class file.
    how to access the variables?
    thanks

    here is the code
    * testbean.java
    * Created on October 31, 2006, 12:14 PM
    package property;
    import java.beans.*;
    import java.io.Serializable;
    public class testbean extends Object implements Serializable {
    public String sampleProperty="test2";
        public String getSampleProperty() {
            return sampleProperty;
    }jsp file
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="java.sql.*,java.util.*"%>
    <html>
    <head>
    <title>Schedule Details</title>
    </head>
    <jsp:useBean id="ConProp" class="property.testbean"/>
    <body>
    Messge is : <jsp:getProperty name="msg" property="sampleProperty"/>
    <%
      out.println(ConProp.sampleProperty);
    %>
    </body>
    </html>out.println(ConProp.sampleProperty) prints null value.
    is this the right procedure to access bean variables
    thanks

  • Converting Java class file to .dll

    Dear all,
    Is there any way to convert a Java class file to a .dll file?
    (Background being that there is a software that only allows callouts to DLLs and the method I have developed is in Java so need to convert it to a .dll)
    Any insight/advice/pointers are most appreciated.
    Thanks much,
    David

    Hi there,
    Yes you can convert a Java Class to DLL file using Microsoft Visual J#.NET (Installation required Visual Studio.NET) you can download it from the microsoft site.
    www.microsoft.com/downloads
    then go for search below in combo box(Visual J#.NET). After installation open new project select class library. write your java code(not fully supported j2se). build your application. All the Java Code is embeded in dll. Found at e.g. C:/JavaToDll/bin/debug/JavaToDll.dll This is a way to convert Java Code to a dll. frankly speaking i do not like .NET (copy of Java Technology must be baned completely).
    Thanks
    Please correct if i am wrong.
    Yahya Kamran (Software Engineer)

  • java.io.File instance .list() not working properly

    i want to get the file, folders in any directory, so i used the File.list() method.
    but it is working in a peculiar manner. first see my simplified code, where the problem i am having::
    public class FileChildTest {
         public static void main(String[] args) {
              try{
                   String[] s=new java.io.File(args[0]).list();
                   for (int i = 0; i<s.length; i++){
                        System.out.println (s);
              catch(java.lang.Exception ex){
    now, say i saved it in c:\MyJava directory. now when i run it with cmd line argument c: in stead of listing the file/folders in c: drive it lists the file/folders of c:\MyJava directory. in any other case its working fine.
    now if i save the file in d:\MyJava\src. again it gives same problem when CLA is d: , but working fine for any other arg.
    now xplain me why is this happening. do i have any fault or what?
    and whats the solution.
    can ne1 pls.

    to b more scecific, in the 2nd case it lists the files/folders of d:\MyJava\src folder.

  • More than one class in single java source file?

    Is there a way to define more than one class in single java source file?
    I get a duplicate class definition error for each extra class, but I am sure there is a way to handle this in JDeveloper.
    Anyone knows how ?

    Please post the question in jdeveloper forum at
    JDeveloper and ADF
    for quick response.
    Regards,
    Anupama
    http://otn.oracle.com/sample_code/content.html

  • UNC paths and java.io.file in Oracle

    Hi,
    I'm just getting to grips with using some basic java in the database. I'm using 8.1.7 on W2K.
    I'm trying to test for the existance of a file on a separate w2k domain:
    import java.io.File;
    public class JFileExists {
    public static int fileexists (String fileName) {
    File myFile = new File (fileName);
    boolean retval = myFile.exists();
    if (retval) return 1; else return 0;
    public static void main (String args[]) {
    System.out.println (
    fileexists (args[0])
    grant javasyspriv to mp;
    function jfn_file_exists (file_in IN VARCHAR2) RETURN number
    AS LANGUAGE JAVA NAME 'JFileExists.fileexists (java.lang.String) return int';
    From the command prompt all is well:
    E:\java>"c:\oracle\ora81\Apache\jdk\bin\java.exe" JFileExists i:\test.txt
    1
    E:\java>"c:\oracle\ora81\Apache\jdk\bin\java.exe" JFileExists \\mpweb1\image\test.txt
    1
    But when loaded into oracle its returning false with the UNC path. (but is ok with a mapped drive to the same path)
    SQL> declare
    2 begin
    3 pa_main.pr_print(to_char(pa_main.jfn_file_exists('I:\test.txt')));
    4 pa_main.pr_print(to_char(pa_main.jfn_file_exists('\\mpweb1\image\test.txt')));
    5 end;
    6 /
    1
    0
    PL/SQL procedure successfully completed.
    The oracleservicesid and listener are starting under a user called oracle_user which is a member
    of the admins and domain admins group.
    mpweb1 is on a separate domain to the database server mpdb1 but it also has a user called oracle_user with the same password.
    oracle_user has full access to the share in question.
    Am I missing something? I was trying to keep the database server and web server on different domains for better security
    - but would things be easier if they were on the same domain?
    Any help much appreciated for this java newbi!
    Thanks,
    Simon.
    null

    I am also having problems with UNC paths. But I cannot access the location even if it is mapped as a drive. In JDK VJM I do not have a problem, but in Oracle it says the file cannot be found and say permission denied. I will try to change the user that starts the database and see if that helps.
    null

  • Java Card File System ...Please reply

    Hi all ,
    I am working on Java Card technology for last one year . Presently I am facing some problem regarding some file concept of java card .
    I know that Java Card 2.1 does not support file system . But I want to simulate the file system in java card using applets . i.e . I want to write an application(applet) , which can simulate the EF , DF in smart card . Whenever APDU command is send to the file system applet , it should generate a Elementary file (EF) or dedicated file (DF) etc and store data to that file.
    Can I do this type of thing using Java Card ? I am really in doubt .
    If you have any idea on this , please let me know your view on this . If you know any open source code for this type of simulated Java card file system , please let me know .
    I am desperately looking for a help .
    regards
    Dibyendu .
    you can contact me to this email
    [email protected]

    dear duran ,
    You have written that
    "Follow the guidelines for the different supported filesystems on the JC"
    But after Java Card version 2.0 , it does not support file system . I am using Java Card 2.1 .
    Could please some sample code to my mail Id , so that I can take a look at it .
    My mail id is : [email protected]
    Please share the idea , as I am really need some help.
    Regards ,
    Dibyendu.

Maybe you are looking for

  • My external hard drive does not appear.

    So I have a 500 GB USB 3.0 HDD. It does not show up in the Finder. It also doesn't show up in Disk Utility, Time Machine, or the terminal command diskutil. I used both USB ports and it still doesn't work. I even tried a normal USB 2.0 cable and it st

  • How to get client Ip address from web service

    Hello folks, I am quite new to web service and developing a web service using netbeans6.0 IDE, where i have to know which client called/used the service, After googling i got code snippet like below inject a WebServiceContext instance into your WebSe

  • 8.1.6 JDBC XA on 8.1.5 server can't find JDBC_XA package

    I'm using Oracle's 8.1.6 XADataSource. I'm enlisting the XAResource associated with an XAConnection with my JTA transaction manager. I'm hitting an 8.1.5 RDBMS server. Apparently, I'm missing the PL/SQL package JAVA_XA. Can I get a .sql for it and lo

  • Merge cells in table (RTF template)

    Hey, everybody! Is it possible to merge cells at runtime on some condition? Edited by: user11367404 on 24.08.2009 6:10

  • BPC 7.5 & Windows 7 Installation

    New Forum User here with a question. We upgraded our enviroment from 7.0 to 7.5 this past weekend, And a few of our users have new computers with Windows 7. What is the installation process for BPC so that the Windows 7 has the correct software to wo