How to extend java.io.File class?

Hi,
I have written the following code.
import java.io.*;
public class MyFile extends java.io.File {
MyFile()
} // end myFile class
I am getting the following errors while compiling. Could any one throw some light on this and tell me what could be the wrong in this?
C:\>javac MyFile.java
MyFile.java:5: cannot resolve symbol
symbol : constructor File ()
location: class java.io.File
^
1 error
Appreciate your help in this regard. Please email me if you find the answer for this.
Thanks & Regards,
Murthy
Email: [email protected]

there's no default File() constructor , so u should write like this:
import java.io.*;
public class MyFile extends File {
     MyFile(String name) {
          super(name);
} // end myFile class
------------------------

Similar Messages

  • How to print the image data stored in object of 'java.io.File' Class in jsp

    I have created a file object for the image file in the system temporary directory.Now I want to display it in my page. please tell,How to print the image data stored in object(in my program it is imgr) of 'java.io.File' Class in jsp

    Create a servlet which gets an InputStream of the file and writes it to the OutputStream of the response and call this servlet in `src` attribute. That's basically all.
    Here's an example which covers the most of the minimum needs: [http://balusc.blogspot.com/2007/04/imageservlet.html].

  • How can I rewrite the java.io.file class to a custom file class?

    Hi All!
    Im new to Java. Well, I did some experiments with small Applets. Because it is not allowed to use Files in an unsigned Applet, I need to know, how I can manage to overwrite the java.io.File class. The background: I have to port some Applications which need file access into Applets.
    I think it is necessary to create a class with the same signature then the Java.io.File that stores the information in an database on the Webserver or read information from there. Then overload the java.io.File with my custom file class.
    Is this possible and, if so, how?
    Thanks!

    Hi yawmark !
    Thanks for the quick answer! My idea to store the filecontent into a database is caused by the plan to make the application-port independent from the workstation executing it. So it would be a nice feature storing the "files" into a database.
    JavaBeginner2009

  • How to convert the javasource file(*.class) to execute file(*.exe)?

    How to convert the javasource file(*.class) to execute file(*.exe)?
    thank you!

    Although i have seen a few programs (that are platform specific) that will embed a small jvm into an exe with your class file, it is generally excepted that you cannot create an executable file using java. The JAR executable file is probably the closest your going to get
    Pete

  • Java.io.File class file

    hi may i know how can i get this java.io.File class file, where can i download it from to use it.

    Nothing..... just a visit from the Deprecation Fairy..... she was a little plastered and removed
    java.io.File by mistake .... :)

  • How to extend the JVue applet class using ActiveX Control

    My SR recommendation was to post this here:
    ) How to Extend the JVue Applet class
    This is the preferred solution. However, when using the ActiveX control, my derived JVue class that is specified in autovue.properties is not being instantiated.
    Your ActiveX bridge looks like it's hard coding a "new JVue()" which means I have no integration hook using the ActiveX control.
    To reiterate, if I extend JVue to add functionality and specify it in the autovue.properties, it is picked up when I run it standalone but if I use the ActiveX component, it is not being picked up.
    I have already read all the documentation, have had web conferences with Mahmood and Jeff Chapman and the engineering staff who recommended this approach as the preferred option.

    We have a need to override certain VueBean/JVue method calls to meet our document handling(documents need to handle metadata information and hence change the document loading cycle, ie markup loading/XRef resolution is dynamic). Also the invokeAction/invokeSubAction do not allow parameter passing(which we have requirements for certain actions again due to metadata) so we would like to override the invokeAction method to include custom processing(we will encode the action with parameters).
    We are already using Custom VueActions for other simpler UI event handling that don't have parameter requirements.
    As I said above, these use cases were relayed to the engineering team and senior staff members in early December and we were told that we could proceed with overriding the main class in the autovue.properties file. I have SR(s) opened with a long thread detailing this so I really don't want to go through this again.
    A custom VueAction does not seem to work because it binds to late in the object call/event stream.

  • How to declare ftp in File class. I want to display filename of file in FTP

    How to declare ftp in File class. I want to display filename of file in FTP server.
    I try
    File f2= new File("ftp://abc:abc1111@ABC/file");
                   String n[] = f2.list();
                   System.out.print(n[0]);
                   Vector filename = null ;
                   for (int i2 = 0; i2 < n.length; i2++) {
                        filename.add(n[i2]);
    but it is not work
    Thank you.

    You can use Jakarta's net-package to connect to a FTP server.
    Download it here:
    http://jakarta.apache.org/site/downloads/downloads_commons-net.cgi
    Here's a small demo:
    import org.apache.commons.net.ftp.*;
    public class FTPTest {
        private boolean isConnected;
        private FTPClient client;
        public FTPTest() {
            isConnected = false;
            connect();
        private void connect() {
            String server = "server.org";
            String username = "user";
            String password = "password";
            client = new FTPClient();
            try {
                client.connect(server);
                client.login(username, password);
                String[] files = client.listNames();
                for(int i = 0; i < files.length; i++) {
                    System.out.println(files);
    isConnected = true;
    disconnect();
    catch(Exception e) {
    e.printStackTrace();
    private void disconnect() {
    if(isConnected) {
    try {
    client.disconnect();
    isConnected = false;
    catch(Exception e) {
    e.printStackTrace();
    public static void main(String[] args) {
    new FTPTest();

  • How to configure java.security file to run j2ee programs

    Hi,
    I am using Sun one application server to run my j2ee programs.
    plz tell me how to configure java.security file inside my appserver so that i can run my servlet program that is using jsse API to create SSL sockets.
    I am not able to follow whats there in java.security file.Kindly tell how to configure it.
    Waiting for ur replies!
    Thanks,
    Akshatha

    Hi,
    I am using Sun one application server to run my j2ee programs.
    plz tell me how to configure java.security file inside my appserver so that i can run my servlet program that is using jsse API to create SSL sockets.
    I am not able to follow whats there in java.security file.Kindly tell how to configure it.
    Waiting for ur replies!
    Thanks,
    Akshatha

  • How to move(migrate) OAF files(class files,PG files) using tool(Kintana)

    Hi,
    How to move(migrate) OAF files(class files,PG files) using tools(Kintana).
    Just want to know process for moving(migrating) OAF Files(class,PG) one instance to over instance(i.e dev to testing) using tools like kintana. We are planning to PVCS as versioning tool.
    Thanks

    New Line Types need to be added to Kintana Workflows and these line types should be able to use the xmlimport/xmlexport scripts.
    We have customized Kintana to migrate forms personalizations using FNDLOAD.
    I think, Change Management team should be able to address this.
    Srini

  • How is the java.lang.StringBuffer class different from the java.lang.String

    How is the java.lang.StringBuffer class different from the java.lang.String class?....

    Read the API.
    http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html
    "Strings are constant; their values cannot be changed after they are created. String buffers support mutable strings."
    Although when possible you should use StringBuilder instead of StringBuffer.
    Always read the API at the very least before asking questions in the forums. Ideally you should do some google searching and poke around for an answer too. Otherwise you will get people barking at you.
    Drake

  • How to Extend Java class in UI Module

    Hi All,
    I am trying to make z for one of the java file GenericSearchDynamicContent.java in the standard package com.sap.wec.app.common.module.catalog.ui.utils. Can anyone please let me know what are steps do i need to follow to extend the same java file in our customer namespace and make use of it.
    Thanks in Advance.
    Regards,
    Rahul.

    Hi Rahul,
    It's upto you whether you want to keep seprate packages for custom changes (then create your own package and keep all the Z class under this) or create a Z_GenericSearchDynamicContent.java and extend this class by GenericSearchDynamicContent.java.
    After doing this you can make your custom changes accordingly and you have to also make the changes in *config.xml (replace this entry GenericSearchDynamicContent by Z_GenericSearchDynamicContent.java.) files as mapping is done there.
    Could you please let me know if you need any further information.
    Thanks,
    Hamendra

  • How to configure Java Properties File location in WLW

    How do we tell Workshop 7.0 where to look for Java properties files (loaded by
    PropertyResouceBundle in code) ?
    Thanks,
    Ray

    Ray,
    The build number indicates that you have not upgraded to Service Pack 2 of
    version 7.0. I will strongly recommend you to do so. That will shield you
    from the issues which were fixed in the 2 service packs.
    Regards,
    Anurag
    "Ray Yan" <[email protected]> wrote in message
    news:[email protected]...
    >
    Raj,
    We are using WebLogic Workshop Build 7.0.1.0.0829.0 on Windows 2000.
    We shut down the WebLogic Server on Solaris 2.6, log off, log back on,startWebLogic
    in production nodebug mode, and re-run jwsCompile on the same source code.The
    error does not occur anymore. Everything seems to be fine now.
    Thanks,
    Ray
    "Raj Alagumalai" <[email protected]> wrote:
    Hello Ray,
    Can you let me know if you are using the GA version of WebLogic Workshop
    or
    if you have the latest Service Pack.
    Thank You,
    Raj Alagumalai
    WebLogic Workshop Support
    "Ray Yan" <[email protected]> wrote in message
    news:[email protected]...
    Anurag:
    Thanks for your response!
    By moving the property files to WEB-INF/classes from WEB-INF, we arealmost there.
    But we have a follow up problem. We use a static initializer to loadthe
    log4j
    property file like this:
    static {
    try {
    ClassLoader cl= (new Log()).getClass().getClassLoader();
    InputStream is = cl.getResourceAsStream(logfile);
    Properties props = new Properties();
    props.load(is);
    PropertyConfigurator.configure(props);
    } catch (Exception e) {
    e.printStackTrace();
    When we run jwsCompile, we keep getting this:
    Compiling: com/****/TestWS.jws
    weblogic.utils.AssertionError: ***** ASSERTION FAILED *****[weblogic.management.Admin
    may only be used on the Server ]
    at weblogic.management.Admin.getInstance(Admin.java:104)
    at
    weblogic.security.internal.ServerPrincipalValidatorImpl.getSecret(ServerPrin
    cipalValidatorImpl.java:79)
    at
    weblogic.security.internal.ServerPrincipalValidatorImpl.sign(ServerPrincipal
    ValidatorImpl.java:59)
    at
    weblogic.security.service.PrivilegedActions$SignPrincipalAction.run(Privileg
    edActions.java:70)
    at java.security.AccessController.doPrivileged(Native Method)
    at
    weblogic.security.service.SecurityServiceManager.createServerID(SecurityServ
    iceManager.java:1826)
    at
    weblogic.security.service.SecurityServiceManager.getServerID(SecurityService
    Manager.java:1839)
    at
    weblogic.security.service.SecurityServiceManager.sendASToWire(SecurityServic
    eManager.java:538)
    at
    weblogic.security.service.SecurityServiceManager.getCurrentSubjectForWire(Se
    curityServiceManager.java:1737)
    at weblogic.rjvm.RJVMImpl.getRequestStream(RJVMImpl.java:434)
    at
    weblogic.rmi.internal.BasicRemoteRef.getOutboundRequest(BasicRemoteRef.java:
    88)
    at
    weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java
    :255)
    at
    weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java
    :230)
    at
    weblogic.jndi.internal.ServerNamingNode_WLStub.lookup(Unknown
    Source)
    atweblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:337)
    atweblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:332)
    at javax.naming.InitialContext.lookup(InitialContext.java:345)
    at weblogic.knex.bean.EJBGenerator$1.run(EJBGenerator.java:101)
    at
    weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManage
    r.java:780)
    atweblogic.knex.bean.EJBGenerator.lookupAdminHome(EJBGenerator.java:84)
    atweblogic.knex.bean.EJBGenerator.ensureAdminHome(EJBGenerator.java:122)
    at weblogic.knex.bean.EJBGenerator$6.run(EJBGenerator.java:660)
    at
    weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManage
    r.java:821)
    atweblogic.knex.bean.EJBGenerator.generateJar(EJBGenerator.java:482)
    at
    weblogic.knex.dispatcher.DispJar.generateJar(DispJar.java:401)
    atweblogic.knex.dispatcher.DispCache.ensureDispUnit(DispCache.java:695)
    atweblogic.knex.compiler.JwsCompile.compileJws(JwsCompile.java:872)
    at
    weblogic.knex.compiler.JwsCompile.compile(JwsCompile.java:619)
    at weblogic.knex.compiler.JwsCompile.main(JwsCompile.java:109)
    ejbc successful.
    Generating EAR ...
    The EAR was generated and we can even deploy it on Solaris. But whatdoes
    the
    AssertionError mean?
    Thanks,
    Ray
    "Anurag Pareek" <[email protected]> wrote:
    Ray,
    ResourceBundle looks for the properties file in the current thread's
    classpath.
    Since a Workshop webservice's project is nothing but a webapp, the
    properties files can be kept in the WEB-INF/classes directory, which
    is part
    of the webapp classpath.
    You can also use
    Thread.currentThread().getContextClassLoader().getResourceAsStream("MyProp
    s
    properties"); to get access to the properties file.
    Thanks,
    Anurag
    "Ray Yan" <[email protected]> wrote in message
    news:[email protected]...
    How do we tell Workshop 7.0 where to look for Java properties files(loaded by
    PropertyResouceBundle in code) ?
    Thanks,
    Ray

  • How to load Java properties file dynamically using weblogic server

    Hi,
    We are using Java properties file in Java code. Properties in java properties file are frequently modified. If I keep these properties file in project classpath or as part of war, I will have to redeploy application after each change.
    We are using Weblogic Server.
    Can you please suggest me how can this properties file be loaded at weblogic server startup. Then in that case, how to refer property file in Java code?
    What is the best practice for this?
    Thanks,
    Parshant

    Another alternative is, keep the property file in any pre-defined location. Write a class which reads the properties from the file and returns the one which is requested by caller and deploy this class. Whenever you have to change the properties just update the property file on server and next call to fetch the property should return the updated one.
    Downside of this approach is file I/O everytime. To overcome that you can actually "cache" the properties in a hashmap. Basically when any property if requested, first check the hashmap, if not found then only read from property file and also update in hash map. Next time same property will be returned from hash map itself. The hash map will be cleared at every server restart since its in the memory. You will also need to build a method to clear the hashmap when you update the values in the property file on server.
    This solution would be suitable for small size files and when network overhead of calling a DB needs to be avoided.

  • Extend java.io.File

    Is it possible to expend File with this constructor?
         public MP3File( File f ) {
    //blah blah...
    Guess not, it gives me an error....any suggestion?

    What was the error message you received. Also show the complete class structure, in that to say, just mention the class definition and the method signatures you have used. Also java.io.File is not a final class which means you can extend File. You cant similarly extend java.lang.String because its a final class.

  • How to run java jar file

    Hello,
    I got a java jar file which contains folders with class file. When I double click on the jar file, it gave a error
    Exception in thread "main" java.lang.NoClassDefFoundError
    How can I run this jar file?
    Thanks,
    CR

    Hello,
    I got a java jar file which contains folders with
    class file. When I double click on the jar file, it
    gave a error
    Exception in thread "main"
    java.lang.NoClassDefFoundError
    How can I run this jar file?
    Thanks,
    CR... and assuming that Jar contains a manifest file, what does it look like? I would guess that the Main-Class entry is incorrect, or that the Jar has external dependencies to other jars not listed properly in the Class-Path entry.

Maybe you are looking for

  • Bluetooth - Connecting two devices at the same time on a Run (Bluetooth Mot headset

    I would like to connect two Bluetooth devised at the same time on my runs.  (Bluetooth Motorola headset (S10-HD) and Polars heart monitor (H7) at the same time)  is that possible? 

  • Problem With LOGON.par

    HI iam using NWDS 2.0.12 version as indicated i have moved the par file into the studio and edited the jsp tages according to my needs by  the system is showing the error Portal Runtime Error An exception occurred while processing a request for : iVi

  • How to Hide user & pass in PORTAL URL

    Hi Experts, I need a help on portal URL. We are using SSA (Spend Analytics) in Portal. One of the option in portal is that you can generate an E-mail Link of a report which goes to users. Link looks like this for end user (They receive it via E-Mail)

  • Installing agent as a non-root user?

    Trying to install OEM agent on Solaris, from the OMS server, I get the following error when setting up the SSH Named Credentials. "The agent installation cannot be performed as a root user. Ensure the user name in the Named Credential is set to a non

  • How to download my Adobe Premiere Elements 8

    About two years ago I recieved an adobe package in connection with the use of my Video camcorder Sony Elegria. It worked well on my old computer, which I have just exchanged for anothger one. Now the system refuses to accept downloading the Adobe Pre