File read/write in Oracle JVM

Are there any known issues around file read/write in Oracle JVM. I finally got around the issue of getting the error that says no permission is there by giving <<ALL FILES>> option, but still I don't see a file being created. Any help is appreciated.
Code:
try{
fwriter = new PrintWriter(new FileOutputStream("debugLog.txt",true));
} catch (IOException ioe) {
System.err.println("IO Exception for Output File" + ioe.getMessage());
Thanks.
-Mujib

A couple of suggestions:
1. (Please don't be offended...) I assume you have some stuff like:
fwriter.println("hello");
fwriter.flush();
fwriter.close();
in your try block?
2. Try catching FileNotFoundException and SecurityException also.
3. Try providing a full path on the file just to make sure it's not buried somewhere odd.
John H.

Similar Messages

  • Missing file read/write feature on Mac OS X?

    HI,
    i am missing the file read/write statistics on Mac OS X. First i thought i just need to enable it in the template editor under "Advanced -> Java Application" but the two list items are simple not there. I ve seen a screenshot somewhere from the JMC where the two options are present but not for me. Can anyone tell me if this is a platform issue or how to enable it?
    Thx
    Marc

    You didn't say which version you are using, but I think what you are seeing is that the file and socket events are not available in JDK 8 only in JDK 7. This is a known regression that will be fixed in the next update to JDK 8.

  • Blob for binary file, read/write problems

    Hi,
    I am relatively new to this type of development so apologies if this question is a bit basic.
    I am trying to write a binary document (.doc) to a blob and read it back again, constructing the original word file. I have the following code for reading and writing the file:
    private void save_addagreement_Click(object sender, EventArgs e)
    // Save the agreement to the database
    int test_setting = 0;
    // create an OracleConnection object to connect to the
    // database and open the connection
    string constr;
    if (test_setting == 0)
    constr = "User Id=royalty;Password=royalty;data source=xe";
    else
    constr = "User ID=lob_user;Password=lob_password;data source=xe";
    OracleConnection myOracleConnection = new OracleConnection(constr);
    myOracleConnection.Open();
    // create an OracleCommand object to hold a SQL statement
    OracleCommand myOracleCommand = myOracleConnection.CreateCommand();
    myOracleCommand.CommandText = "insert into blob_content(id, blob_column) values 2, empty_blob())";
    OracleDataReader myOracleDataReader = myOracleCommand.ExecuteReader();
    // step 2: read the row
    OracleTransaction myOracleTransaction = myOracleConnection.BeginTransaction();
    myOracleCommand.CommandText =
    "SELECT id, blob_column FROM blob_content WHERE id = 2";
    myOracleDataReader = myOracleCommand.ExecuteReader();
    myOracleDataReader.Read();
    Console.WriteLine("myOracleDataReadre[\"id\"] = " + myOracleDataReader["id"]);
    OracleBlob myOracleBlob = myOracleDataReader.GetOracleBlobForUpdate(1);
    Console.WriteLine("OracleBlob = " + myOracleBlob.Length);
    myOracleBlob.Erase();
    FileStream fs = new FileStream(agreement_filename.Text, FileMode.Open, FileAccess.Read);
    Console.WriteLine("Opened " + agreement_filename.Text + " for reading");
    int numBytesRead;
    byte[] byteArray = new byte[fs.Length];
    numBytesRead = fs.Read(byteArray, 0, (Int32)fs.Length);
    Console.WriteLine(numBytesRead + " read from file");
    myOracleBlob.Write(byteArray, 0, byteArray.Length);
    Console.WriteLine(byteArray.Length + " written to blob object");
    Console.WriteLine("Blob Length = " + myOracleBlob.Length);
    fs.Close();
    myOracleDataReader.Close();
    myOracleConnection.Close();
    This gives the following console output:
    myOracleDataReadre["id"] = 2
    OracleBlob = 0
    Opened D:\sample_files\oly_in.doc for reading
    56832 read from file
    56832 written to blob object
    Blob Length = 56832
    My write to file code is:
    private void save_agreement_to_disk_Click(object sender, EventArgs e)
    string filename;
    SaveFileDialog savedoc = new SaveFileDialog();
    if (savedoc.ShowDialog() == DialogResult.OK)
    filename = savedoc.FileName;
    // create an OracleConnection object to connect to the
    // database and open the connection
    OracleConnection myOracleConnection = new OracleConnection("User ID=royalty;Password=royalty");
    myOracleConnection.Open();
    // create an OracleCommand object to hold a SQL statement
    OracleCommand myOracleCommand = myOracleConnection.CreateCommand();
    myOracleCommand.CommandText =
    "SELECT id, blob_column " +
    "FROM blob_content " +
    "WHERE id = 2";
    OracleDataReader myOracleDataReader = myOracleCommand.ExecuteReader();
    myOracleDataReader.Read();
    Console.WriteLine("myOracleDataReader[id] = " + myOracleDataReader["id"]);
    //Step 2: Get the LOB locator
    OracleBlob myOracleBlob = myOracleDataReader.GetOracleBlobForUpdate(1);
    Console.WriteLine("Blob size = " + myOracleBlob.Length);
    //Step 3: get the BLOB data using the read() method
    byte[] byteArray = new byte[500];
    int numBytesRead;
    int totalBytes = 0;
    FileStream fs = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.Write);
    while ((numBytesRead = myOracleBlob.Read(byteArray, 0, 500)) > 0)
    totalBytes += numBytesRead;
    fs.Write(byteArray, 0, byteArray.Length);
    Console.WriteLine("numBytes = " + numBytesRead + " totalBytes = " + totalBytes);
    Console.WriteLine((int)fs.Length + " bytes written to file");
    fs.Close();
    myOracleDataReader.Close();
    myOracleConnection.Close();
    This gives the following console output:
    myOracleDataReader[id] = 2
    Blob size = 0
    0 bytes written to file
    If I manually add the blob file using the following:
    DECLARE
    my_blob BLOB;
    BEGIN
    -- load the BLOB
    my_bfile := BFILENAME('SAMPLE_FILES_DIR', 'binaryContent.doc');
    SELECT blob_column
    INTO my_blob
    FROM blob_content
    WHERE id = 1 FOR UPDATE;
    DBMS_LOB.FILEOPEN(my_bfile, dbms_lob.file_readonly);
    DBMS_LOB.LOADFROMFILE(my_blob, my_bfile, DBMS_LOB.GETLENGTH(my_bfile), 1, 1);
    DBMS_LOB.FILECLOSEALL();
    COMMIT;
    END;
    COMMIT;
    The write to file works perfectly. This tells me that there must be something wrong with my code that is writing the blob to the database. I tried where possible to following the Oracle article using large objects in .NET but that (along with most things on the internet) focus on uploading text files.
    Thanks in advance.
    Chris.

    myOracleCommand.CommandText = "insert into blob_content(id, blob_column) values 2, empty_blob())";
    OracleDataReader myOracleDataReader = myOracleCommand.ExecuteReader();
    This looks wrong, you shouldn't be using ExecuteReader unless you expect to get a result back. Try using ExecuteNonQuery to do the insert.

  • File read write

    Hi guys:
    its an easy question so i will explain as simply and as elborately as possible:
    i am reading from a file
    public void appendFile() {
        try {
          BufferedReader in = new BufferedReader(new FileReader("temp\\text.txt"));
          BufferedWriter out = new BufferedWriter(new FileWriter("temp\\text.txt", true));
          String str;
          String res;
          while ( (str = in.readLine()) != null) {
            res = process(str);
            if (res != null) {
              try {
                out.write(res);
                out.close();
              catch (IOException e) {
                log.info(e.toString());
          in.close();
        catch (IOException e) {
      }what i am trying to do is : read a file read though and where i get a certain string i replace it with another string :
    no looking at this code tell me if i will be writing at the same position or not.. i dont really remember if the cursor for readline and write line is the same :
    forexample : i read through ten lines and find the string i am looking for and i write at that moment witha new strinmg:
    1) will it write on the same line and write over the text that is already written
    OR
    2) will it write on the same line and move the text on that (that i am intending to replace) line to the next..
    OR
    3) will it write in the beginning of the file

    found the error i think : in FileWriter ("",true);
    the true defind that it hould be written in the end of file ... and not the begiining
    now i will see if the flase will write to the beginning or where the readline was done...

  • Can I batch change user access to folders & file read-write permissions?

    I had a corrupted user account on my iMac and after weeks of trying repairs I followed a forum suggestion to delete my account.
    Before doing so I synced all my document folders and files (since 2004) over my LAN to an external hard drive that was attached to my MacMini. I then deleted the iMac account.
    Next I backed up my Mac Mini user account with Time Machine. I then created a new iMac User account on the iMac and let the iMac access Time Machine to bring over all my MacMini preferences, settings, desktop, etc. I now have a fully functioning iMac user account.
    Here is the problem. I attached the USB external drive directly to my iMAC. I can access some of the folders and files on the external hard drive. Most of them refuse to let me acces the folder or open a file. If I use the GET INFO command I see an "_unknown" user with "read and write". I see an "everyone" with "no access". I can individually change each folder and file to allow my user account access and give myself permission to read and write the files. I cannot delete delete the "_unknown" account.
    It will take me days to individually change each folder and file manually like I am now doing.
    Is there a way to use Automator to add my user account to the folder or file and give me read and write folder and file permissions?
    Or is there any other way to do this in a batch change?
    Is there something I need to do to the external files right now that will ensure that I can access them if either computer crashes and I need to replace the MAC? I would hate to have to go through this again. Would having a MAC server instead of an external drive solve this?
    I am using MAC OS 10.6.8 with the most recent updates installed (as of today).
    Thanks,
    Sandi Dickenson

    Select the icon of the external drive in the sidebar of a Finder window, and open the Info window. In the "Sharing & Permissions" section of the window, click the lock icon and authenticate. Make sure you have read & write access to the volume by changing the settings if necessary. Then, from the action menu (gear icon), select "Apply to enclosed items."
    The "_unknown" user and group are assigned automatically to files on a volume with the "Ignore permissions" option set.

  • Getting file read/write/execute permissions.

    How can I get the read, write, and execute permissions for either a named file, or a File? I'm only interested in the permissions exposed to whatever user is running the VM.
    System.getSecurityManager() either returns null or some default SecurityManager that denies everything... I guess you have to set that explicitly, which doesn't really help me here.
    I've been browsing through the docs but I can't find anything that returns a FilePermission. It's highly possible that I missed something, though.
    Thanks in advance,
    Jason Cipriani
    [email protected]
    [email protected]

    Thanks for replying.
    That was the first thing I looked out. As it turns out, FilePermissions aren't for getting permissions on named files. Rather, they are for dealing out permissions that you set yourself, or representing permissions internally. If you look at the constructor for java.io.FilePermission, you'll see that, in addition to a file name (which, btw, can be anything since the constructor throws no IOException), you must also provide a list of permissions.
    So, unfortunately, that class can't take a file name and provide you with a permission list... it's just there for you to use to store permission information.
    That frustrates me a lot, because the name, FilePermissions, makes it seem like the most promising class to use for my application.
    Thanks, though,
    Jason.

  • Urgent!!! Need help in file read/write data to a serial port

    Hi,
    I really need someone's help in order for me to complete my project. I have attached a vi which I have taken from an example and integrate to my project. In the vi, I have managed to get the encoder counts using Ni 9411. I need to read/write that data from ni9411 to ni9870 without using any serial port as they are connected to a NI 9104 chasis. May I know whether I am correct in writing the data to my ni9870 port using the vi I have attached? Does anyone know how i can convert the number of counts to a 8-bit data/byte so that I can send the data through the RS232 port? I really need someone's help as I need to finished in 2 weeks time.
    I have also attached an vi on controlling the epos2 controller using instrument driver. Does anyone know how can i integrate this vi to the fpga vi (the one which I need to read/write data to 9870) as I need to send those data to control my epos2 controller.
    Please help me!!!
    Attachments:
    Encoder Position & Velocity (FPGA).vi ‏23 KB
    SINGLEMOTORMODIFIED.vi ‏17 KB

    Afai,
    As I allready suggested you here, call your local NI Office and ask for assistance!
    You really need assistence in a higher level that we can provide via the forums. Otherwise I don't see a chance for you to finish your project in time.
    1. Convert I32 to U8 to write it to the 9870 could be done like this:
    2. The vi to control the epos2.
    There is NO way ( absolutely NO way) to port this vi to FPGA. It's based on VISA calls, uses an event-structure, both are not available at the FPGA.
    The only thing you could do is to analyze the VI, the instruction set and design an FPGA vi which handles the specific instructions you would need.
    I have no experience with epos2 and I'm not 100% sure if this would work as you would like to use it. And doing this needs deep knowledge of LabVIEW, VISA, Instrument Drivers, the epos hardware, FPGA programming, and so on... 
    Christian

  • File read write program output not coming correct

    this code is compiling without issues but the output is not what i am expecting .. the contents of delta.txt are as follows
    *4014254420*
    *2897449776*
    *4207405601*
    and the output thats coming is
    +4014254420+
    +40142544204207405601+
    +4207405601+
    its not reading the 2nd line somehow
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.File;
    import java.io.*;
    import java.io.FileWriter;
    import javax.swing.*;
    import java.util.Scanner;
    public class testloop
              static int i;                                             
               static char c;                                               
               static int j = 1;     
                    static String filename;                                                  
      public static void main(String[] args)  throws IOException 
    try {
         FileReader fmi = new FileReader("delta.txt");
         FileWriter fmo = new FileWriter("Updated.txt");
         BufferedReader br = new BufferedReader(fmi);
                   String temp=null;
                        do{
                        temp = br.readLine();
                        if(temp.startsWith("*"))
                             String tempc = temp.substring(1);                         
                             System.out.print(tempc+"\n");
                            long tp = Long.valueOf(tempc);
                             System.out.print(tp);                    
                   else
                   fmo.write(temp);
                        }while((temp=br.readLine()) != null);
                   fmi.close();
                   fmo.close();
                   }catch (FileNotFoundException e){ System.out.print("not found");     }
                   catch (IOException e){System.out.print("io"+e);
                   e.printStackTrace();
        also if i use the following delta.txt
    **4014254420*
    **2897449776*
    **4207405601*
    mmm+
    i get the output as
    +4014254420+
    +40142544204207405601+
    +4207405601Exception in thread "main" java.lang.NullPointerException+
    at testloop.main(testloop.java:33)*
    its not writing the text to the file updated.txt
    Edited by: adhiraj on Nov 27, 2007 6:58 AM

    You are getting the next line twice.
    do{
                        temp = br.readLine();
                        if(temp.startsWith("*"))
                             String tempc = temp.substring(1);                         
                             System.out.print(tempc+"\n");
                            long tp = Long.valueOf(tempc);
                             System.out.print(tp);                    
                   else
                   fmo.write(temp);
                        }while((temp=br.readLine()) != null);You need to change your code around so that you only call
    temp=br.readLine();once per iteration of the loop.

  • File Read/Write Help Please!

    Hi,
    I am trying to get my program to write an object (or just its varibles) to a file and then be able to read them out again and assign them to their title. i.e be able to read String bo, int car, and int[][] cost to a file (doesn't matter what as long as I can save it and then open it at a later date).
    I really can not figure it out, but I will include my simple test code.
    public class Bob//contains the stuff I want to save
         int car= 10;
         int cost[][]= {{1000,10},{1744,47733}};
         String bo = "Bob";
    import java.io.*;
    import java.util.*;
    public class ObjectS
         public static void main(String args[])
              new ObjectS();
         public ObjectS()
              Bob abc = new Bob();
              try
              {//This code is most likely crud, so I really need help here.
                   FileOutputStream out = new FileOutputStream("theTime");
                   ObjectOutputStream s = new ObjectOutputStream(out);
                   s.writeObject("Today");
                   s.writeObject(abc);
                   s.flush();
              catch(FileNotFoundException e){}
              catch(IOException e){}
    }

    It has already been pointed out that you need to use 'Serializable' and that you need to do more than just ignore exceptions. SO, to spell it out
    public class Bob//contains the stuff I want to saveshould be
    public class Bob implements Serializable //contains the stuff I want to save
    int car= 10;
    int cost[][]= {{1000,10},{1744,47733}};
    String bo = "Bob";
    import java.io.*;
    import java.util.*;
    public class ObjectS
    public static void main(String args[])
    new ObjectS();
    public ObjectS()
    Bob abc = new Bob();
    try
    {//This code is most likely crud, so I really need
    help here.
    FileOutputStream out = new
    FileOutputStream("theTime");
    ObjectOutputStream s = new ObjectOutputStream(out);
    s.writeObject("Today");
    s.writeObject(abc);
    s.flush();and this might be better as
    s.close();
    catch(FileNotFoundException e){}
    catch(IOException e){}and these should do more than just ignore the exceptions! Exception are your freinds so as a very minimum you need something like
    catch(FileNotFoundException e){
    e.printStackTrace();
    catch(IOException e){
    e.printStackTrace();

  • PJC File read/write security fix!

    Hi,
    While attempting to access the client file system. I was running into checkRead/ checkWrite exceptions.
    Initially, I managed to get around this problem by doing the operation in a separate thread.
    I decided to try something different. I
    expanded f60all.jar and resigned it with
    my own certificate. Now I have no
    restrictions on reading/writing to the file
    system, even from the main thread of execution.
    It appears that jinitiator 1.1.8.10 still
    has problems handling jar's with different
    certificates.
    I thought this might be useful to some people.
    Regards
    Jason

    The steps:
    1) I installed a 1.1.8 JDK from Sun.
    2) I set the JDK_HOME to this jdk.
    3) I used the oracle cert-maker to create
    a new certificate JPELL.
    4) I signed my own jar file (fileupload.jar)
    with this certificate.
    5) I made a copy of the f60all.jar, I then
    extracted it. I removed the META-INF/
    directory and recreated the f60all.jar.
    6) I signed the new f60all.jar with JPELL
    certificate.
    7) I copied new f60all.jar back to server
    and changed the ARCHIVE attribute to
    reference "nca/f60all.jar,nca/fileupload.jar"
    instead of "f60all.jar,nca/fileupload.jar"
    8) I registered JPELL.x509 with jinitiator.
    These are the steps I took. I am using
    forms 6.0.8.11.3 on Solaris 2.8. I am
    running jIntiator 1.1.8.10.
    Cheers
    Jason

  • File read/write contention?

    Hi!
    Can a file be written to ... the same time another thread is checking for a change of this same file? (ie: long timeStamp = file.lastModified();)
    ...without contention.
    Thanks!

    Brutal Juice!! : ) ....OK you explained that very well. Thank-you!
    I just now realized that I don't need to write this data to a file anyway (no need to) ....... In my app I just need to direct incoming data to my jTextArea window (visual storage of this data)for later processing by another thread.
    I'll explain,
    I read data in from my serial com port (port must be monitored 24/7)
    This serial com port data is directed to a jTextArea(so I can see, store and process this data)
    Another thread will process this data(stored in the jTextArea), extracting the data(line for line) of interest to me then deleting this data out of the jTextArea forever.
    My question now is:
    How do I store my newly arriving serial com port data if the other thread is currently processing the stored data in my jTextArea? .... I need to have it stored to an appendable storage buffer some how ..... then to have this data copied into my jTextArea when the other thread is finished with data already in the jTextArea.
    My data coming in on the com port is a low duty, single line "call record" after someone ends their telephone conversation.
    (can you tell I'm very new to JAVA) : )
    Thanks!

  • File Read/Write Question

    Hello Everyone, nice to see a large Flex user group.
    I am a beginner to flex and I have a simple question. I am
    currently writing a web application in Flex. I compute some data
    and all I want to do is take this string and write it to a file on
    the local disk. In other words, writing some data to a location on
    the disk. Please note that this is a web application. I did some
    searching and could not find anything that works...since it is a
    flex web application they have some tight security. I am guessing
    we might need some help from javascript or something but do not
    know how to do that. If anyone could help me with this it would be
    really helpful. Thanks.

    This is correct - web apps cannot write to the local disk.
    Imagine you went to a web site that has a banner SWF and that SWF
    was written to open a file on your disk and fill up your disk
    drive. Or perhaps worse, the SWF opens a file and reads your
    personal and financial information. You just cannot be sure what is
    going to happen when you visit a web site. So we made the Flash
    Player as secure as possible and removed the ability to read or
    write local files.
    AIR, on the other hand, does not have that restriction. So
    you might want to look into that if writing to the local disk is
    important.

  • Help with best solution for file read/write in web app (not local files)

    Problem in a nutshell...
    I have an AIR app to process images..  organize and add information. This information is read and written to local XML files. This is working fine (if still a be messy... still learning this OOP stuff ;O)
    So... now I am developing my Web gallery app to consume these files for a web gallery (unique concept huh? ;O)
    Reading them in was easy with the Declaration block....
    <fx:Declarations>
    <fx:XML id="galleryXML" source="gaXML.xml"/>
    <fx:XML id="baXML" source="baXML.xml"/>
    <fx:XML id="prjXML" source="prjXML.xml"/>
    <s:XMLListCollection id="galleryList" source="{galleryXML.item}"/>
    <s:XMLListCollection id="baList" source="{baXML.item}"/>
    </fx:Declarations>
    But I want the owner to have a maintenance mode where information can be added/changed and saved back to the XML file on the server. I have read about all the different services available, but I am not that familiar with them. Also I will have no way of knowing what services the user will have available on their host. So... help me out in understanding what the most universal solution would be to be able to read and write XML files stored on the host along with the application.
    I hope that is clear enough, but ask away if any more details will help in the discussion.
    Thanks
    Bob Galka

    Hi Jeba,
    Whenever u are using *"Thread.currentThread().getContextClassLoader()"* Code inside your application means the Files (Resources) which you are looking right now must be poresent in the CLASSPATH...(Bootstrap classloader/ System ClassLoader/ Application ClassLoader/ Sub Module ClassLoader...).
    So when we place a resource (example XML or Properties file) inside the "WEB-INF/classes" directory then it means that file (resource) is available as part of the Module Classloader....So the above code getContextClassloader() will be able to find that resource easily.
    Thanks
    jay SenSharma
    http://middlewaremagic.com/weblogic (Middleware Magic Is Here)

  • Windows 7 applicatio​n file read/write problems

    I'm building a few programs using labview 2009 on an XP machine. I can build these programs and have them work fine with any windows XP machine. Recently I've gotten a Windows 7 machine. I've installed the labview runtime, and daq mx without any problems. The programs seem to run fine.
    However when I have to read or write to files nothing happens. . For instance with one program I log data and output that to a TDM file with the other I read that data and do something. I get the dialog to save the file but after I hit save no file is made. Likewise if I bring a premade TDM file from another machine I get the open dialog box but no data is imported. No Errors are reported.
    Trouble shooting steps taken: I've tried running with administrator rights, with XP compatability mode, in the windows XP virtual machine. Has anyone run into something like this?
    Solved!
    Go to Solution.

    Good Morning. I'm having an identicalissue, but I wanst able to figure out this solution. In simialr fashion (LV 2009 on Win7 machine), I've typically written my executables to write data files to c: so when I deploy the software, I dont have to account for different names. On Win7, this is no longer possible. Can somebody please point me towards a way to define a path constant so I can write and read from a file in a known location without the use having to select a path? Sorry, Ive been looking all night for the solution, just havent been able to get it worked out.  (I did instal the USI files with the Installer) I appreciat the thoughts.

  • File read/write in separate threads

    If I have a file in process of being written out, and another thread comes along to read it, will it block until the first thread closes the file, or do I have to handle that programatically?

    I believe it will work if all the threads don't care about the content of the file, it would be rare though.
    So if you code these threads and want to make sure reading after writing or something similar, you got to take care of that using wait(), notify(), etc.
    PC

Maybe you are looking for

  • Support for SX-10

    Is the new low cost SX-10 supported on the Webex TP service?  

  • 11g memory @ solaris10

    On Solaris 10 4Gb Ram, how much memory could be allocated to Oracle 11G instance? If I set memory_target=1200M the server starts okay and immediately. If I set memory_target=2500M the server takes very very long time to start - at some point over 45

  • Installed Java Runtime and Perian without authentication prompt

    OSX LION 10.7.3 MacBook Pro 2.2 GHz i7 Late 2011 It was my understanding (and experience thus far) that any changes to the operating system, including the addition of new applications, would prompt admin authorization and require a password.  I recen

  • Only run script if required by input

    I'm trying to setup a sql script that runs various other scripts from within. A number of these scripts will only need to be run if the user requires them to be. I've tried similar to the following, to no avail: ACCEPT run_scripts PROMPT 'Are extra s

  • FCP with External devices/Mini dv decks

    I just bought FCP and I wanted to know if I should turn on my external device (jvc mini dv deck) before I open FCP or after I open FCP. Thanks, David