aspose file tools*
The moose likes I/O and Streams and the fly likes Create a file at runtime Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Create a file at runtime" Watch "Create a file at runtime" New topic
Author

Create a file at runtime

Arch Tiwari
Greenhorn

Joined: Feb 07, 2003
Posts: 6
Hi,
Basically I would like to create and write to a file at runtime. The problem is basically doing the same on the UNIX server.
I have given the path/filename as an environment variable in web.xml & pass this variable as a parameter to the FileOutputStream instance. My problem is creating the file in the directory I require.
I have a directory structure as "/devel/logs/logs" on the unix platform which is outside the OC4J container. I am unable to access this directory.
Say I create the variable as -
"/devel/logs/logs/myapp.log" , on the Unix server, this throws a null pointer error. However, on my local m/c the same file gets created within- /devel/logs/logs
Now say I create the variable as -
"\devel\logs\logs\myapp.log" , on the Unix server, this creates a file by the name -- "\devel\logs\logs\myapp.log" under the OC4J home directory.
What I want to know is, how to I create a file in the
"\devel\logs\logs\" directory on the UNIX server.
Please note that this directory is outside the OC4J container and that since it is a UNIX platform I will not be able to give anything like "c:\devel\logs\logs"
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1135

Hi Arch,
Your question is not terribly clear to me -- but I'll try to answer it, anyway (if you don't mind :-)
I believe you are using OC4J (I assume stand-alone version -- and not the one embedded in "JDeveloper" -- but I don't know what version number) running on a Windows machine (but again, I don't know which version of Windows) and that you want some component in your application (that you have deployed to OC4J) to write log messages to some file that is supposed to reside on another, UNIX machine (yet again, I don't know what UNIX version nor what type of machine) which is situated on the same local directory (i.e. LAN) as the Windows machine (that is running OC4J).
Assuming the above is correct, then you have two possibilities (in my opinion):
  • use a file URL which has the format: file://host ort/path/to/file
  • create (and use) a network mapping for the UNIX machine from the Windows machine. At my place of work we use "samba" software to do this. Unfortunately, I don't know much about it (I just use it).


  • However, your problem may also have to do with permissions. The Windows user (that "owns" the OC4J instance that is running) may not have permission to create files on the UNIX machine. But yet again, I can't help you with a more detailed answer since I didn't find enough information in your question to allow me to.
    And if the above is totally useless to you, then please excuse me.
    Hope it helps (anyway).
    Good Luck,
    Avi.
    Arch Tiwari
    Greenhorn

    Joined: Feb 07, 2003
    Posts: 6
    Hi Avi,
    Just to give you a little clarification --
    I have deployed my EAR file in the OC4J container on the Oracle 9iAS Server. This is installed on a UNIX sun solaris box.
    I need to access a file on the same Unix box but the directory is outside the OC4J home directory.
    Thanks,
    Arch
    Avi Abrami
    Ranch Hand

    Joined: Oct 11, 2000
    Posts: 1135

    Arch,
    Well, I see I was way off on that one :roll:
    Are you familiar with these Web sites/pages?
    http://technet.oracle.com/products/ias/content.html
    http://technet.oracle.com/tech/java/oc4j/content.html
    http://www.orionserver.com
    http://www.orionsupport.com
    http://www.atlassian.com
    http://www.elephantwalker.com
    Hope this helps you.
    Good Luck,
    Avi.
     
    It is sorta covered in the JavaRanch Style Guide.
     
    subject: Create a file at runtime