Is it possible to create a file object from a resource?

Hi all
Is it possible to create a File from a resource call rather than from a path
e.g.
File myFile= new File("C:/j2sdk/sampledir/mypage.htm");is how im doing it now
how can i call it from a resource something like
File myFile= new File(this.getClass.getResource("mypage.htm"));

you may be right
im trying to load a file into a string then display that string
my resource thingy isnt working anyway :s
[code[
URI pTURI=null;
URI pBURI=null;
try
pTURI= new URI(this.getClass().getResource("/resources/prev_header.htm").toString());
pBURI= new URI(this.getClass().getResource("/resources/prev_fullpac.htm").toString());
catch(URISyntaxException e)
warnUser("URI Error");
File previewTop = new File(pTURI);
File previewBtm = new File(pBURI);
im getting this error
java.lang.NullPointerException
at cssCreator.cssCreator.setPreview(cssCreator.java:1263)
at cssCreator.cssCreator.<init>(cssCreator.java:48)
at cssCreator.cssCreator.main(cssCreator.java:1681)

Similar Messages

  • Is it possible to create a development object from the development tab?

    Hello All,
    One the central concepts of SAP Solution Manager is that you perform almost all activities starting in Solution Manager. As I understand, it is not possible to create a customer development such as a program from the development tab in SSM. You first have to logon to the 'satelite' development system and create the object. Then you can register this object at the development tab. 
    Is this correct?
    Thanks in advance.

    Hi,
    You are right, you have to create your objects in your satellite system (its obvious).
    This object can be against any servicedesk message or any requirement for a particular business process, thus keeping track of all the developments process wise, request wise.
    Hope this solves your problem.
    Feel free to revert back.
    --Ragu

  • Create a File object from a file in a .jar

    i looked for 2 hours...
    i tired this:
    URL url =  MyClass.class.getResource("filename.dat");
    File file = new File(url.getFile());i give up.

    The problem is that the file inside a Jar file is not
    a file. The jar file just contains a stream of bytes
    in the format needed to make the Jar file. Jar files
    are not folders like in the directory. So to get at
    the contents of the Jar file you need to read the Jar.
    The getResource method returns the URL which is a
    file URL, but this only works because Java has
    handlers that deal with getting the contents from a
    Jar file based on this type of URL. A URL cannot
    just be made into a file. I'm not sure that the File
    object can handle this type of file URL (I guess not
    or we wouldn't be having this discussion). So really
    it just depends what you want do. If you want to
    extract the file, just read the data in from the
    inputstream gotten from the URL, or better just call
    getResourceAsStream(), and read the bytes into an
    array. After this, you can do whatever, write it as
    a file to the hard drive, convert to a string, get
    the size based on the array length. makes sense, but how could i get an InputStream into an array, dont i need the size of the array first? and i dont think i can use InputStream.available()to figure it out... i tired downcasting to a FileInputStream yet no avail.

  • How to create File object from InputStream

    Hi everybody
    Can I know a way to create a File object from InputStream object
    Here's my code:
    URL url = loader.getResource(xsdFile); //Thats a schema file..not to worry
    InputStream istream = url.openStream();
    Now from that 'istream' I need to build File object.
    Thank you all

    didn't know fileinputstream was made to read url objects ; in the doc, it just says "A FileInputStream obtains input bytes from a file in a file system." ; according to me, website is something outside the filesystem, but i could be wrong
    edit: thought from the beginning it was all about FILEinputstream whereas it just says "inputstream" in the post ; my bad, it's still early in the morning here X)

  • Can I create a network object from CIDR format or do I need to use IP - netmask?

    Have a cisco ASA running ASA V 8.3
    Wondering what the correct syntax is or even if it is possible to create a network object from a list of IP's in CIDR format? 
    Typically just do this:
    Create network-object
    object-group network name
    network-object 1.2.3.0 255.255.255.0
    Would like to do this: 
    network-object 1.2.3.0/24
    thanks!

    Hi,
    As far as I know the ASA does not support entering a network/subnet mask in such format in any of its configurations.
    - Jouni

  • Is it possible to create a file in servlet context? pls help me

    Is it possible to create a file in servlet context? pls help me

    Surely it is possible.File file = new File(path, name);

  • Creating File objects from all files in a folder.

    Hi, I'm not too brilliant of a programmer, so this may be an obvious one that I could find in the API.
    My goal is to compare files for similarities and then give some output, that's not too important.
    My question is: How do I create an array of File objects from a folder of *.txt files, without creating each individually? Is there a way to simply get all the files from the folder?
    File I/O is still pretty new to me. If I didn't give a good enough explanation, please say so.
    Thank you very much!

    Note by the way that a File represents an abstract pathname, the idea of a file as a location. It doesn't specify the file's contents, nor does it require that the file it represents actually exists. A better name might be "theoretical file" or "directory listing entry".
    So getting a whole bunch of File objects is itself perhaps not necessary (although it could be useful).
    To expand on reply #1, look for File methods whose names start with "list".

  • Create File Object from a remote file

    Hi,
    I would like to know about how to create a new File object from a file in a remote machine, it is a web application, i have the remote route of the file, and if I need the ip of the remote machine, I would like to know how to get it too.
    File fileobject = new File(�What do I have to put here or before or whatever?);
    Thank you very much.
    J.

    First, from the technical point of view you can't create a File object unless it's a file on the computer where the code is running. It doesn't matter if you have an IP address or something, if you haven't mapped a drive to it you can't create a File object.
    But more importantly, you can't just reach out from your server and grab a file from the client's computer. That's an obvious security violation and if you didn't realize that you shouldn't be designing web applications yet. If you want a file uploaded then you have to provide the client with an HTML form where they select a file to be uploaded.

  • Creating a File object in a JSP page

    Hi,
    I am trying to create a File object in my JSP page by passing it a relative path. The jsp page is in 'website/testfolder/index.jsp' and the File is in 'website/photos/1.jpg'. In my jsp page i do the following:
    <% File f = new File("../photos/1.jpg");
    boolean test = f.isFile(); %>
    The value returned is false. I am trying to figure out why it can't locate the file.
    Thanks

    You have to use absolute paths. You can get the absolute path for the given relative path by ServletContext#getRealPath().

  • Is it possible to create a Report Object in a menu?

    Hi all,
    I 'm working on an oracle report wherein the user will not give any parameter.
    They would like to view the report by clicking on the menu option for this report and it should then open the report in an new browser window
    in pdf format.
    My question:
    Is it possible to create a report object in the menu?how can we do this?
    I'm working on Oracle reports version Report Builder 10.1.2.0.2
    TIA

    Thanks for your prompt reply.
    Through form I'm able to create report object and report is displayed successfully.
    I'm using the following code:
    DECLARE
              report_id Report_Object;
              ReportServerJob VARCHAR2(100);
              rep_status VARCHAR2(50);
    BEGIN
              report_id:= find_report_object('Report1');
              SET_REPORT_OBJECT_PROPERTY(report_id,REPORT_OTHER,'vouno='||:vouno||' paramform=no');
              ReportServerJob:=run_report_object(report_id);
              rep_status:=REPORT_OBJECT_STATUS(ReportServerJob);
              WHILE rep_status in ('RUNNING','OPENING_REPORT','ENQUEUED')
              LOOP
                        rep_status := report_object_status(ReportServerJob);
              END LOOP;
              IF rep_status = 'FINISHED' THEN
              WEB.SHOW_DOCUMENT('http://sushma:8889/reports/rwservlet/getjobid'||
              substr(ReportServerJob,instr(ReportServerJob,'_',-1)+1)||'?'||'server=rep_sushma','_blank');
              ELSE
                        message('Error when running report');
              END IF;
    END;
    I'm not able to use the same code in Menu, as there is no way to create report object "Report1"
    Or is there any was to create object.
    So in place of report_id:= find_report_object('Report1');
    I used report_id:= find_report_object('c:\.... *.RDF');

  • Is it possible to create a rotating object in Muse?

    Is it possible to create a rotating object in Muse? I have a round logo and I want it rotating.

    HI
    If you are looking for an animated logo, which rotates in 360 degree, it is not possible in Muse. You can create an animation in Edge animate and import the animation in Adobe muse.,

  • Is it possible to create .ncd file without using MAX?

    Is it possible to create .ncd file without using MAX? I am trying to read the data given by hundreds of possible Arb. IDs on one of the CAN port without having to create it from the MAX.
    Thank you

    Hi,
    the NI-CAN driver software does not provide functions/VIs to generate
    *.ncd files. However the *.ncd file format is just plain XML (ASCII text). Take a
    look at the example.ncd file that gets installed with NI-CAN
    (<ProgramFiles>\National Instruments\NI-CAN\):
    <?xml version="1.0" encoding="UTF-8"?>
    <nican_config version="0.1">
    <saved>8/8/2005,17:58</saved>
    <message name="TransmissionFluids">
      <id extended="0">82</id>
      <dbc>C:\Program Files\National Instruments\NI-CAN\example.ncd</dbc>
      <conflicts>0</conflicts>
      <bytes>6</bytes>
      <interface>1</interface>
      <comment></comment>
      <channel name="ClutchPressure">
        <conflicts>0</conflicts>
        <bitfield start="0" bits="8" order="0" type="1"/>
        <linear_scaling factor="1.600000e+001"
    offset="0.000000e+000" max="4.000000e+003" min="0.000000e+000"
    default="0.000000e+000" unit="kPa"/>
        <comment></comment>
      </channel>
    </message>
    </nican_config>
    Thus, you could generate *.ncd files with simple file I/O. Having XML-specific file I/O functions simplifies this task.
    -B2k

  • Can I create a File object without writing it to the disk?

    I need construct a mechanism where I can "write" instructions to a file and then FTP this file to a remote system. It is basically a Telnet-like integration for a system that does not support Telnet. Once the file is on the remote device, it knows how to read the file and process its instructions.
    I would like to logically create this File object, by that I mean that I would like to use a FileWriter object to write the text instructions to the File, then use the Jakarta Commons NET API to FTP the file to the remote system. My question: can I create this File object without the file actually being written to the file system? Can the File just be memory resident for this creation and FTP?
    There could be tens of thousands of these transactions per day and I would like to just avoid any kind of deletion strategy, if I can. Thanks.

    Apart from the questionable decision to try and mess with the File object, I think the answer to (my guess at) your original question is "Yes".
    Jakarta Commons/Net FTP can upload to a server from any input stream you like. It doesn't have to be a FileInputStream. In particular it could be a ByteArrayInputStream, which reads from a byte array in memory.

  • Unable to create a Driver object from driver with Media type string CTC PHO

    Hi All,
    I am trying to develop a siebel cti adapter for avaya.
    I have loaded a custom dll into siebel server but it is throwing error "SBL-CSR-00500: Unable to create a Driver object from driver C:\Mydriver\cti.dll with Media-Type-String CTC Phone ".
    It has been long time without any progress.
    Please help
    Thanks
    Nishant

    Hi tomhowell,
    According to your description, my understanding is that you got an error when you created a site from a custom site template after migrading SharePoint 2010 to your server.
    Did you have the original solution file of the site template? Please re-deploy the solution to your SharePoint site, then create a site from the new site template, compare the result.
    Also use  SPDisposeCheck to indentify the memory leak:
    http://archive.msdn.microsoft.com/SPDisposeCheck
    http://www.fewlines4biju.com/2012/11/detected-use-of-sprequest-for.html
    Here are some similar posts for your reference:
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/3a25eb86-8415-4053-b319-9dd84a1fd71f/detected-use-of-sprequest-for-previously-closed-spweb-object-please-close-spweb-objects-when-you?forum=sharepointdevelopmentprevious
    http://social.msdn.microsoft.com/Forums/en-US/50ce964f-94a6-4fda-abc0-caa34e7111f1/error-detected-use-of-sprequest-for-previously-closed-spweb-object-occurs-when-new-site-gallery
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • Access file object from flex web app

    Hi all,
    I want to access file object from flex web app. What should i do?
    I have to take array from my XML. In XML there will be only dir path. So for taking file name from dir i have to access it and have to perform for loop on that dir.
    What should I do?
    Any Ideas?
    Thanks,
    -CK

    Hi Michael
    My question is that I dont want to give name of images in XML file.
    In XML file there will be only path of image directory. So I need to find all image name from that image directory.
    Thats why I want to access file object.
    Any ideas?    

Maybe you are looking for