Reading all files on directory using "utl_file" package...

I need to read all files in directory via PL/SQL. I don't know
name files (are data dynamics create for automation system),
only I know your extensions.
Can I do this using the package "utl_file" or I need to create
program in another language (C, C++, for example)?
Any ideas...
Thanks.

Hi,
you can't do that with the UTL_FILE package (it can't retrieve
file names).
A very simple solution would be, if you created on OS-level a
file which contains the filenames of directory and then read this
file using UTL_FILE. With the information on all file names you
can enter a loop which opens and reads all files again using
UTL_FILE.
A more mundane solution could be to use the features on the iFS.
Cheers
Gerald

Similar Messages

  • Reading all files in directory

    Hi
    I need to read all the files inside a directory where my app resides. I have the following:
    File file = new File(args[0]);
    Reader reader = new FileReader(file);
    BufferedReader bufferedReader = new BufferedReader(reader);
    This works fine for one file, but i have many files I would like to
    read in this directory. I was hoping I could just do:
    java MyApp *
    but it doesn't work. thanks in advance for any help.
    J.

    rtfm
    http://java.sun.com/products/jdk/1.1/docs/api/java.io.File.html#list()

  • Use JFilechooser to read all Files inside Directory

    Hello gang!
    I was wondering how to modify the code below to allow it to select Files AND Directories. If it selects a Directory, I want it to be able to look in that directory for all .jpg files, and return a list of all the jpg files to me. It does not have to search in any subfolders..only the folder that the user selects with the jfilechooser.
    File defaultDirectory = new File("C:\\"); // Set Default Directory
    JFileChooser fc = new JFileChooser( defaultDirectory );
    fc.addChoosableFileFilter(new ImageFilter());
    fc.setFileView(new ImageFileView());
    fc.setAccessory(new ImagePreview(fc));
    fc.setMultiSelectionEnabled(true);
    int returnVal = fc.showDialog(currentFrame, "Attach");
    if (returnVal == JFileChooser.APPROVE_OPTION)
    File files[] = fc.getSelectedFiles();
    for (int b=0; b < files.length; b++)
    String pathName = files.getAbsolutePath();
    storeInfoRef.setFiles(pathName);
    defaultDirectory = files[0];
    fc.setCurrentDirectory( defaultDirectory ); // New Default Dir
    else
    { System.out.println("Attachment cancelled by user"); }

    I have solved my problem. For anyone with a similar problem here is the code I added since my last post
    JFileChooser fc = new JFileChooser( defaultDirectory );
    fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    fc.addChoosableFileFilter(new ImageFilter());
    fc.setFileView(new ImageFileView());
    fc.setAccessory(new ImagePreview(fc));
    fc.setMultiSelectionEnabled(true);
    int returnVal = fc.showDialog(currentFrame, "Attach");
    if (returnVal == JFileChooser.APPROVE_OPTION) //If Button Pressed
    File files[] = fc.getSelectedFiles(); // Get Users Selections
    for (int b=0; b < files.length; b++) // For Each Selection
    if ( files.isDirectory() ) // If User Selected a Directory
    File[] folderFiles = files[b].listFiles(); // Get contents of folder
    log.append("For folder: " + files[b].getName() + "." + newline);
    int count=0; // Keeps Count of # of Image Files
    for ( int i=0; i < folderFiles.length; i++ ) // For each item in folder
    if( (folderFiles.getName().endsWith(".jpg") ) || //If file is an Image
    (folderFiles[i].getName().endsWith(".jpeg")) ||
    (folderFiles[i].getName().endsWith(".bmp") ) ||
    (folderFiles[i].getName().endsWith(".gif") ) ||
    (folderFiles[i].getName().endsWith(".tif") ) ||
    (folderFiles[i].getName().endsWith(".tiff") ) )
    System.out.println( folderFiles[ i ].getName() );
    String pathName = folderFiles[i].getAbsolutePath(); //Get Path of File
    storeInfoRef.setFiles(pathName); //Save Path of File
    log.append(" Attaching file: " + folderFiles[i].getName() + "." + newline);
    count++; //Increase Counter
    if ( count == 0 ) // If No Images
    log.append( " There are no Image Files to Attach" );
    else if ( files+.isFile() ) // If User Selected File(s)
    String pathName = files[b].getAbsolutePath();
    storeInfoRef.setFiles(pathName);
    System.out.println ("File Size: " files[b] +" is "+files.length() );
    log.append("Attaching file: " + files[b].getName() + "." + newline);
    defaultDirectory = files[0];
    fc.setCurrentDirectory( defaultDirectory ); // New Default Dir
    else
    { log.setText("Attachment cancelled by user." + newline); }

  • How to read a files in directory and its subdirectories

    I wants to read all files in directory, its subdirectory and further till end the files in the subdirectory of subdirectories.
    I have some idea the I can do this by using recursive function, using the functions isDirectory(), File.list() etc.
    How much you can please help me. (via code of logic)

    import java.io.*;
    import java.net.*;
    public class MyCon
    public static void main(String args[]) throws
    IOException
    File file=new File("c:/");
    openDirectory(file,"");
    System.in.read();
    static void openDirectory(File file,String indent)
    String[] string=file.list();
    String path=file.getAbsolutePath();
    for(int i=0;i<string.length;i++)
    File temp=new File(path+"/"+string);
    if(temp.isDirectory())
    openDirectory(temp,indent+" ");
    else
    System.out.println(indent+temp.getName());

  • How  to read all files  under a folder directory in FTP site

    Hi Experts,
    I use this SQL to read data from a file in FTP site. utl_file.fopen('ORALOAD', file_name,'r');
    But this need to fixed file name in a directory. However, client generate output file with auto finename.
    SO do we have any way to read all file by utl_file.fopen('ORALOAD', file_name,'r');
    We need to read all file info. because client claim for security issue and does not to overwirte output file name,
    we must find a way to read all file in output directory.
    Thanks for help!!!
    Jim

    If you use Chris Poole's XUTL_FTL package, I believe that contains functions that allows you to query the directory contents.
    http://www.chrispoole.co.uk/apps/xutlftp.htm
    Edited by: BluShadow on Jan 13, 2009 1:54 PM
    misread the original post

  • Archiving files generated by PL/SQL program using UTL_FILE package

    Dear All,
    We have on PL/SQL package that is generating some data files using UTL_FILE package in one specific directory.
    I am working on concurrent program of type host(unix script) to move generated file to some archive folder.
    Now the problem is owner of the files generated by PL/SQL is oracle and file permissions of the generated files are 644(Only read permission for group and others).
    Concurrent program is using an another os user applmgr to execute the script attached with concurrent program.
    Because applmgr is not having write permission on the files, hence mv command is failing.
    Please suggest me how to resolve this issue.
    Regards
    Devender Yadav

    Hi;
    I just think that, you can create one sh which is chancing permission of related path owner for applmgr user and put it on crontab and it can run every 1 min.
    Regard
    Helios

  • Permissions on files created using UTL_FILE package

    The files created on unix using UTL_FILE package have permisisons rw- - - - - - -.(600). I want them to be created with permissions 640.(rw-r - - - - - ).i.e read access to the group also. The umask setting of the unix account of the oracle instance are 137. Is there any way to create the files with the required permissions.

    So SQL*Plus is on your PC? I'm assuming you mean 'call' as in the windows cmd.exe command?
    Sheesh this is like getting blood from a stone.
    In that case you must be connecting via the listener and not internally.
    In which case the umask comes from the umask that was set in the environment of the OS user who started the listener process.
    Thats not necessarily the same as the owner of the oracle software (normally 'oracle').
    If sysdamin joebloggs logs in and starts the listener manually in a shell, then the umask applied to all shadow processes started by the listener is whatever jobloggs umask was when he typed the command 'lsnrctl start'. The umask of the owner of the oracle software, or your umask, is utterly irrelevent.
    So if you don't like the umask for files created by processes spawned by the listener, stop and restart the listener in a shell where you have explicitly set the umask to what you want it to be.
    Really starting the listener should be scripted and the correct umask is put in the script just before the call to 'lsnrctl start'.

  • Creating Error log files using UTL_FILE package on a remote machine

    Database Version: 10g Release2
    OS Platform: Sun Solaris
    I have been asked to log errors to OS files rather than tables. So, i wanted to use UTL_FILE package. But the client doesn't want to store these files on the same server where the database is running(as specified in UTL_FILE_DIR). Is there a way i could get these files created on a remote machine(client).

    I believe what others are suggesting is that your stored procedure continues to log to a table and a separate process be created that runs on the machine you want the file to be created on which reads the log table and writes to a log file.
    If that is not an option, can you expose the directory on the remote machine you want to write the file to as a file share that can be mounted by the database server? If you can, you could write errors there using UTL_FILE. However, it would probably be a bad idea. If you're logging an error already, that implies that something has gone wrong. Making an error logging process dependent on a remote server being available and properly mounted with appropriate privileges at the instant the error occurs just creates more sources of failure that would prevent you from logging an error, which would prevent you from being able to debug the problem or even know it existed without a report from a user.
    Justin

  • HTML  Parsers and reading all files in a directory

    Hello all,
    I was wondering if there was a html parser included in java. I am writing a program where I want to be able to search all the files in a directory tree for a particular string. I was able to read one file in a single directory but not in any other directory. How would I go about writing code to be able to access all files in directory that has multiple sub folders.
    Also, when I started to write my program I tried to use the DOM XML Parser to parse my html page. My logic behind this decision was that if you look at html code it is an xml document. But as I was trying to run my program I noticed that I had to convert my html document into xml format. I really don't want to have to build my own html parser. Is there a html parser that is included in Java. Oh my program is just your basic text program. No interfaces.
    Thanks for any help that you can provide
    Hockeyfan

    a particular string. I was able to read one file in
    a single directory but not in any other directory.
    How would I go about writing code to be able to
    access all files in directory that has multiple sub
    folders.
    You can do that several ways.
    Most likely you'll end up with some sort of recursive iteration over the directory tree.
    Not hard to write, somewhat harder to prevent memory problems if you end up with a lot of data.
    Also, when I started to write my program I tried to
    use the DOM XML Parser to parse my html page. My
    logic behind this decision was that if you look at
    html code it is an xml document. But as I was
    trying to run my program I noticed that I had to
    convert my html document into xml format. I really
    don't want to have to build my own html parser. Is
    there a html parser that is included in Java. Oh my
    program is just your basic text program. No
    interfaces.
    A VALID xhtml document is a valid XML document.
    Problem is that most HTML isn't xhtml.
    Another problem is that most HTML is fundamentally broken even to its own standards (which have always been based on SGML on which XML is also based).
    Browsers take that into account by being extremely lax on standards compliance and effectively making up tags as they go along to fill in the missing ones in the trees they parse.
    That's however not a standardised process and each browser handles it differently (and as a result most html will render differently in different browsers).
    Java contains a simple HTML parser in Swing, but it's primitive and will only parse a subset of HTML 2.0.
    There are almost certainly 3rd party libraries out there that can do better, both free and/or commercial.

  • Read all files in chield and their chield's directory

    I am trying to make a program which read all files in a directory and its subdirectory like scandisk program of window's operating system. I gause this I can do via recursion using the methods isDirectory(), File.list() etc. Please help me to implement this problem in code.
    Regards
    yogesh

    you guys should collaborate,
    http://forum.java.sun.com/thread.jsp?forum=4&thread=153110&start=0&range=30#443719

  • Need to generate the excel file with diffrent sheets using utl_file package

    Hi,
    Sorry for previous message in which I had missed the usage of " UTL_FILE " package
    I need to generate the excel file with diffrent sheets . Currently I am generating the data in three diffrent excel files using
    " UTL_File " package and my requirement is to generate this in a single excel file with diffrent sheets.
    Please help on this
    Thanks & Regards,
    Krishna Vyavahare

    Hello 10866107,
    at Re: How to save a query result and export it to, say excell? you can find links to different solutions. At least the packages behind second and fourth link support more than one worksheet.
    Regards
    Marcus

  • Create a file and store it in the database using UTL_FILE package

    Hello.
    I'm using UTL_FILE package to store data from a table into an excel file but I don't know how to store this file in a table with a BLOB field the database at the same time. I want do do this because I will use it in a Oracle Portal.
    Anybody has any idea how to do this?
    Thanks & Regards,
    Alexandra

    From Asktom
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:232814159006

  • How to Read all files inside resource Folder inside Jar?

    I have a Jar file,,,, The program reads for resource files in the resource folder inside the Jar. I want my program to read all files inside this folder without knowing the names or the number of files in the folder.
    I am using this to make an Applet easy to be updated with spicific files. I just want to add a file inside the resource folder and Jar the program and automatically the program reads what ever is in there!!
    I used the File class to get all file names inside the resource folder. it works fine before Jarring the program. After I jar I recieve a URI not Herarichy Exception!!
    File fold=new java.io.File(getClass().getResource(folder).toURI());
    String[] files=fold.list();
    I hope the question is clear!!

    How to get the directory and jar file that you class resides in:
    // returns path and jarfile (ex: /home/mydir/my.jar)
    public String getJarfileName()
            // Get the location of the jar file and the jar file name
            java.net.URL outputURL = YourClass.class.getProtectionDomain().getCodeSource().getLocation();
            String outputString = outputURL.toString();
            String[] parseString;
            int index1 = outputString.indexOf(":");
            int index2 = outputString.lastIndexOf(":");
            if (index1!=index2) // Windows/DOS uses C: naming convention
               parseString = outputString.split("file:/");
            else
               parseString = outputString.split("file:");
            String jarFilename = parseString[1];
           return jarFilename;
    }If your my.jar was in /home/mydir, it will store "/home/mydir/my.jar" in jarFilename.
    note: getLocation returns "file:/C:/home/mydir/my.jar" for Windows/DOS and "file:/home/mydir/my.jar" for windows, thus why I look for the first and last index of the colon so I can correctly split the string.
    If you want to grab a file in the jar file and get an InputStream, do the following:
    import java.io.*;
    import java.util.Enumeration;
    // jar stuff
    import java.util.jar.*;
    import java.util.zip.ZipEntry;
    public class Jaris
       private JarFile jf;
       public Jaris(String jarFilename) throws Exception
           try
                           jf = new JarFile(jarFilename);
           catch (Exception e)
                jf=null;
                throw(e);
       public InputStream getInputStream(String matchString) throws Exception
           ZipEntry ze=null;
           try
              Enumeration resources = jf.entries();
              while ( resources.hasMoreElements() )
                 JarEntry je = (JarEntry) resources.nextElement();
                 // find a file that matches this string from anywhere in my jar file
                 if ( je.getName().matches(".*\\"+matchString) )
                    String filename=je.getName();
                    ze=jf.getEntry(filename);
          catch (Exception e)
             throw(e);
          InputStream is = jf.getInputStream(ze);
          return is;
       // for testing the Jaris methods
       public static void main(String[] args)
          try
               String jarFilename=getJarfileName();
               Jaris jis = new Jaris(jarFilename); // this is the string we got from the other method listed above
               InputStream is=jis.getInputStream("myfile.txt"); // can be used for xml, xsl, etc
          catch (Exception e)
             // this is just a test, so we'll ignore the exception
    }Happy coding! :)
    Doc

  • Newbie question -  How to read all files for a backup

    Hello all,
    I have two users on my iMac. I am an administrator and the other user is a Standard user.
    From my account, I wish to run backup software that will backup the entire "User" directory. The problem I am having is that when I run the backup software (fyi: iBackup),
    it complains that it cannot read the files in the other user's account.
    I notice that when I browse to the other user's account, all the directories in their home folder are locked.
    How can I run my backup software so that it can read all files in the User directory?
    Thank you kindly!
    Jeff
    17" iMac Core Duo   Mac OS X (10.4.6)  

    Hi kneecarrot !
    I don't know if this will suit your needs, but one easy way of backing up other user's stuff is via the terminal . If you have an admin accountm just use:
    sudo ditto -rsrcFork /Users /Volumes/"nameof_anotherharddrive"/Users
    This will perform an identical clone of all your users home direcories for backup purposes. To restore the bkd'up files, just reverse the lines:
    sudo ditto -rsrcFork /Volumes/"nameof_anotherharddrive"/Users /Users
    ATTENTION: Be aware that it will restore the files to the exact structure and contents it was when backed up, erasing all new and modified files!! You may however copy just the files/folders you want to recover, e.g.:
    sudo ditto -rsrcFork /Volumes/"nameof_another_harddrive"/Users/"usera"/Documents /Users/"user_a"/Documents
    IMPORTANT: As with all terminal commands... be careful, think twice and double-check the syntax. You may want to test with non-critical stuff or demo user accounts first.
    Good luck,
    Michael
    MacBook Pro   Mac OS X (10.4.6)   2 Gig RAM

  • How to bundle all files and directories in a package?

    how to bundle all files and directories in a package?
    i plan to put all image files, .class files and some other files together.and then double click the package to execute the program.
    should i use jar?is there a link for tutorial or example?
    thanks in advance

    http://java.sun.com/docs/books/tutorial/jar/

Maybe you are looking for

  • IPad Photo App Photo Album

    On the iPhone the Photo app has a Camera Roll album and a Photo Library album. Basically the Photo Library album contains the images from the iPhoto iTunes sync on the Mac and the Camera Roll contains iPhone local images. That is what one might expec

  • Using InDesign CS6 onWindows PC.  Apple icon and traffic lights in L top corner are missing.

    Using InDesign CS6 onWindows PC.  Apple icon and traffic lights in L top corner are missing and so are some of the editing features.  I fixed this once before by accident but can't remember how I did it.  All I remember is it had something to do with

  • Suggestions for express card/cingular

    I'm looking for the best options for an express card/34 for macbook pro that will work with Cingular service (only available service option for offshore in the Gulf of Mexico region). I see that Cingular will soon be offering a GT Max 3.6 express car

  • How to make format for macBook pro retina display 13 inch Yosemite

    Hi , I want to format and erase everything in my mac because I want to sell it. - MacBook Pro Retina Display 13 inch - OS X Yosemite thanks

  • Adding actionListener to JComboBox

    Hi there I have added actionListener to a JComboBox. I only want the actionPerformed() get called when the user choose the item in the JComboBox, however, it also get called whenever I change the items in the JComboBox. I have tried to call the Actio