File Lising in Unix

How do I avoid infinite loops when listing files in unix directories when there are symbolic links to directoies? here is my peace of code:
if (f.isDirectory()) {
for (int j = 0; j < f.list().length; j++) {
list(f.listFiles()[j]);
When I call the method list, recursively, it causes an infinite loop if the directory is a symbolic link to another directory. Thanks

You can keep track of which directories you have recursed, and don't recurse them again.

Similar Messages

  • To read flat file from a unix server

    We need to read a flat file from a Unix server, where our Database is located.
    The location gets created correctly.
    But while we are trying to import files from the location in Design Center , we get an error that "directory does not exists", although the directory has all the permissions.
    Can someone please suggest how should we create the location so as it can read the files.
    Please Reply ASAP......

    We have started Design Center on a local machine(Windows Machine) with uaer as repository owner of the server,
    In the design center we can not sample the file till we import it,
    can you please tell how to sampe the file without importing it.
    Also a location pointing to server location gets easily created on the design center and the file module points to that location only, but when we try to import the file through that location, it says directory does not exists, although oracle user has all the read write permissions on the directory......
    Please help!

  • Difference in reading a text file in Windows & Unix

    I have a code which is working fine in windows but is stopping after reading the first line of a text file in
    Unix. The code is something like below:-
    declare
    file_handle text_io.file_type; /*running form*/
    filename varchar2(60);
    v_line varchar2(200);
    begin
    message('before fopen');
    filename:=:file_name;message(filename);
    file_handle:=text_io.fopen(filename,'R');
    loop
    begin
    text_io.get_line(file_handle,v_line);
    --:line:=v_line;
    exception
    when no_data_found then
    text_io.fclose(file_handle);
    message('NO MORE DATA IS FOUND ');
    temp:='stop';
    exit;
    when others then
    text_io.fclose(file_handle);
    message('ERROR ');
    exit;
    end;
    mob_no:=substr(v_line,1,10);
    begin
    message(' Mobile NO is '||mob_no);
    message(' Mobile NO is '||mob_no);
    exit when temp='stop';
    end loop;
    commit;
    message('File SUCCESSFULLY LOADED........');
    message('File SUCCESSFULLY LOADED........');
    end;
    Is there any difference in reading a text file in Windows & Unix.
    I hope, my question is clear. Please help in solving the doubt as it is urgent.
    Regards.

    There is no difference in reading a file - you use TEXT_IO in the normal way. However there is of course a difference in the format of text files between Unix and Dos so if you had say transferred your test file from Dos to the Unix box for testing strange things might happen if you had not transferred in ASCII mode.

  • File transfer from UNIX server to Windows server path

    Hello Experts, (Gud Even Gud Aft & Gud Mor)
    Is there a way to transfer file from UNIX server(Oracle database), to Windows server? All I know if Windows path. I am able to read the file as it is on server, however it does not recognize Windows directory at all.
    If you can share some documents around this to study, I will be grateful.
    Regards,

    34MCA2K2 wrote:
    Is there a way to transfer file from UNIX server(Oracle database), to Windows server? All I know if Windows path. I am able to read the file as it is on server, however it does not recognize Windows directory at all.Yes it is possible. Samba on Unix sharing the directory containing the file. NFS on the Unix server sharing the directory containing the file. FTP server on Unix allowing the file to be read and copied. OpenSSH on the Unix allowing the file to be read and copied via scp (secure copy).
    But seeing as this is an Oracle database forum (not an operating system forum), and the subject matter is the database server languages SQL and PL/SQL, here is a PL/SQL solution.
    Create a table using the BFILE data type for referencing the files on the Unix o/s. Provide a web enabled procedure for downloading the files via HTTP using a web browser. This procedure will look something as follows:
    --// URL example: http://my-server.my-domain.com/MyDAD/MySchemaName.StreamFile?fileID=1234
    create or replace procedure StreamFile( fileID number ) AUTHID DEFINER is
            mimeType        varchar2(48);
            fileName        varchar2(400);
            lobContent      BLOB;
    begin
            --// read the LOB from a table (this example uses the
            --// Apex file uploads table - change it to your own files table)
            select
                    f.filename,
                    f.mime_type,
                    f.blob_content
                            into
                    fileName,
                    mimeType,
                    lobContent
            from    FLOWS_FILES.WWV_FLOW_FILE_OBJECTS$ f
            where   f.id = fileID;
            --// format a basic HTTP header that describes the file stream send
            OWA_UTIL.mime_header( mimeType, FALSE );        -- e.g. text/csv text/plain text/html image/gif
            HTP.p( 'Content-Disposition: attachment; filename='||fileName );
            HTP.p( 'Content-Length: ' || DBMS_LOB.GetLength(lobContent) );
            OWA_UTIL.http_header_close;
            --// now write the BLOB as a mime stream using the Web Procedural Gateway's
            --// doc load API
            WPG_DOCLOAD.download_file( lobContent );
    exception when OTHERS then
            --// Decide what HTML to generate (if at all) if there is a failure
            --// (usually not a good idea to show database errors to the
            --// web browser client as that can provide technical details
            --// that could be useful for exploiting the database)
            HTP.prn( 'StreamFile() failed with '||SQLERRM(SQLCODE) );
    end;
    / On Windows, IE can be used interactively to copy the file across. For automation (via PowerShell or console jobs), use a command like tool like wget* to download the file.
    If you do not want to use SQL or PL/SQL as the file copy mechanism, then please close this thread (mark as answered) and take your question to an appropriate forum.
    <i>* - see http://gnuwin32.sourceforge.net/packages/wget.htm</i>

  • File Finding on Unix plateform

    hey, I have a quick question when your doing a recursive file search/scan whatever, on unix/linux you have can symbolic links that can potentially point back to the parent directory or multiple directories above the immediate parent directory. Java interprets these links as folders, whats the best way to prevent infinite loops when scanning for a file on a unix platform. essentially, how do you determine a link from a folder in java? any really simple way?
    Thanks in advance

    If there are no symlinks supported for a particular platform then the method should always return false!Likewise the isResourceFork() should return false if the given platform (and/or file system) does not support resource forks - whatever they might be in other platforms.
    And isShortcut() should return false if the given platform does not support Shortcuts.
    And isUnixDomainSocket() should return false if the given platform does not support Unix Domain Sockets.
    And isNamedPIpe() should return false if the given platform (and/or file system) does not support named pipes (fifos).
    And isMessageQueue() should return false if the given platform does not support message queues or if it supports them but not though file names.
    And isCatalog() should return false if the given platform does not work with the catalog/member paradigm.
    And isSequentialFile() should return false if the given platform does not support the notion of sequential files but considers the files a a stream of bytes as modern OS'es do. (In good old mainframe days, sequential and index-sequential files were supported by the OS.)
    ...etc...

  • Download Excel file in the Unix directory of Application server

    Hi Friends,
    I have a requirement  of downloading the Excel file in the Unix directory path of the application server,i just need your inputs,it would be great help if you can send any sample coding for downlading the file in the Unix directory?
    Regards
    Dinesh

    You can use the following fm
    RZL_READ_FILE
    or
    use OPEN DATASET FOR INPUT.

  • How to upload pdf file format in unix file directory?

    how to upload pdf file format in unix file directory?

    Hi Karthikeyan,
    If you have PDF internal table with you, You can follow the below method to upload into Unix directory.
        DATA:file_path TYPE char100 VALUE '/usr/sap/tmp/rep_out.PDF'.
        OPEN DATASET file_path FOR OUTPUT IN BINARY MODE.
        IF sy-subrc EQ 0.
          LOOP AT it_pdf.
            TRANSFER it_pdf TO file_path.
          ENDLOOP.
        ENDIF.
        CLOSE DATASET file_path.
    Thanks
    Venkat.O

  • Photoshop .psd files converted to Unix Executable files

    I'm an illustrator and I store my art on CDs and DVDs. After a period of time my files are converted from Photoshop .psd files to Unix Executable files and I can't open them. What can I do to get my work back??? -and keep this from happening in the future. Why does it do this????
    Thanks for any help.

    The file sizes range from 22.2 MB to 67.9 MB.
    Size isn't the issue then. Linc was asking that question because we see that with other file types. Older fonts in particular, which have all of their data in the resource fork. If that gets stripped, you end up with a zero byte file.
    Does that mean I'll have to go through the Adobe authorization process for Photoshop again?
    If the version of Photoshop you're currently using is already activated, then no. Either way, it has nothing to do with .psd files showing as UNIX executables.
    In Windows, any file that doesn't have an association to a program is displayed as a white, dog-eared piece of paper with the Windows logo in the middle. That's Windows' way of saying, "I have no idea what this is." In OS X, (except for those files which actually are UNIX executables), displaying them as such is OS X's way of saying the same thing.
    I thought I was home free when the icon changed to a thumbnail picture of the illustration, but PS refuses to open it saying it is not a Photoshop file. ???
    Now that is weird. As of Snow Leopard, Apple put the old Type and Creator codes to rest. It will read them as a last resort to try and identify an older file, but none of Apple's applications add them to any file they save. For better compatibility with Windows, and OS X's own underlying UNIX core, file extensions have taken their place. So adding a .psd extension should have worked. Without playing with one of your files, I couldn't tell you why Photoshop declared it wasn't a valid .psd image.
    On a side note, Apple added Uniform Type Identifiers to OS X to keep things separate. A big problem in Windows is that multiple apps may use the same file extension. EPS is a big one in printing. So you have Photoshop, Illustrator, Freehand, Quark and others all using .eps for Encapsulated PostScript files. However, Windows can only associate one application to any given extension. So if Illustrator happens to be the one tagged to .eps files, it will try to open any file ending in .eps, no matter what program actually created it. OS X keeps them separate with Uniform Type Identifiers. So even though multiple files may have .eps file extensions, the extra metadata keeps track of what program it actually belongs to.
    This is what is part of the LaunchServices database, and was why it was my first suggestion. If that database is wonky, you'll see weird things like this. Have you tried clearing it yet?
    The files are fine when newly burned to CD. It is only months, or years, later that they become Unix Executable Files.  This has happened to just about all of my CD backups and it's frustrating to think that CD backup doesn't work across newer OSs and Photoshop upgrades. I suspect that may be the problem, but it just shouldn't happen.
    That shouldn't make a difference. I've got a bunch of very old files created in Photoshop back from OS 8 on CD. No file extensions, as nothing did at the time. Just Type and Creator codes. They all open fine in PS CS5.5 in Snow Leopard, though the native Photoshop files do need to have a .psd extension added.

  • Where are the MMB files stored in unix box

    Hi all,
    Can anyone tell where are the MMB files stored in unix box. Thanks in advance.
    Regards,
    Sandeep V

    Hi Thomas,
    Thanks for the reply, I got the FNDMENU.mmb file , but Iam not able to find the menu item which Iam searching for. There are some special menu items like SPECIAL , SPECIALB and SPECIALC. So, when I select release from plan menu item special27 is called , but Iam not able to find release in this menu. Can you please help me in this regard.
    Regards,
    Sandeep V

  • Copy Files Between Two Unix Computers

    Hi,
    I am trying to write a piece of code that will copy bunch of files from one Unix computer on to another Unix computer. On windows it seems to be pretty straight but on Unix I am trying to understand best way of copying the files. I don't have much expertise in Unix.
    Is using FTP the only option for Unix?
    I am not able to create a FILE object by referring to a file on some other Unix box? I tried new File("//unixbox2/temp/123.txt");
    Please let me know the different ways to copy files between Unix computers.
    Thanks
    Gautham

    This's a simple example of how you can send a file form one computer to another
    import java.io.*;
    import java.net.*;
    public class Prf extends Thread {
         public void run() { //Read form file and writer to socket
              try {
                   Thread.sleep(100);//sleep(100) while server is getting ready to accept connection
                   System.out.println("Connecting...");
                   Socket soc = new Socket("localhost",4070);
                   OutputStream outS = soc.getOutputStream();
                   FileInputStream fis = new FileInputStream("input.dat");
                   int i = 0;
                   byte[] b = new byte[1000000]; //1MB buffer
                   for(;;) {
                        i = fis.read(b); //read from file (i - number of read bytes)
                        if (i != -1) {// checking for end of data
                             outS.write(b,0,i); //write portion (0..i) of bytes to socket
                        } else {
                             break;
                   fis.close();
                   outS.close();
                   soc.close();
              } catch (IOException e) {
                   System.out.println(e.getMessage());
              } catch (InterruptedException e) {
                   System.out.println(e.getMessage());
         public static void main(String[] args) {//Read from socket and write to file
              Prf prf = new Prf();
              try {
                   ServerSocket sSoc = new ServerSocket(4070);
                   prf.start(); //start writer
                   Socket soc = sSoc.accept();
                   System.out.println("Connection's accepted");
                   InputStream inS = soc.getInputStream();
                   FileOutputStream fos = new FileOutputStream("output.dat");
                   int i = 0;
                   byte [] b = new byte[1000000]; //buffer
                   while (true) {
                        i = inS.read(b);//read from socket (i - number of read bytes)
                        if (i != -1) { //check for end of date
                             fos.write(b,0,i); //write portion (0..i) of bytes to file
                        } else {
                             break;
                   fos.close();
                   inS.close();
                   soc.close();
                   sSoc.close();
              } catch (IOException e) {
                   System.out.println(e.getMessage());
    }

  • How to compile form orginal file(*.fmb) in UNIX environment

    These days, i encounter a problem, i create a form application in Windows2000 or WindowsXP environment, then i compile this .fmb file to .fmx, then i transport this .fmx file to Unix environment which is our Application Server, the Oracle Application Server is in this Unix environment, i put this file in the directory which is directed in the Forms_Path variable, however, when i started to run this application by entering a valid url, the message shows that this fmx file is not runtime file, someone told me that i should recompile the orginal file under unix environment, so i transport the orginal file(.fmb) to unix environment, then i want to use the f90genm tool to compile the .fmb file, however, it shows that this command can not execute, it shows that can not open a lib file under:/project/.../../..,however, this directory does not exist at all, what case this error? i also use f90gen command, it shows: can not execute/finish creation, i want to know, how to use the two commands and what parameters i should set before using the commands? thanks

    If you are talking about forms 10g then here is the method
    1) run x windows interface on your machine
    2) login to linux server
    $ export DISPLAY=<IP address of machine>:0.0
    $ frmcmp.sh module_type=form module=myform.fmb userid=user/password@connectstring compile_all=yes
    Regards
    Anuj

  • File Upload in UNIX Problem in using fileaccess.HttpUploadBean

    Hi,
    Some one please help me on File uploading in UNIX using fileaccess.HttpUploadBean.
    My program is working fine for windows , but when i am running same profram to upload the file in Unix Environment it is giving exception.
    fileaccess.properties for UNIX.
    fileaccess.basedir = /usr
    Under /usr i have tmp directory, and in my beanUploadExample.jsp i have defined userdir = "tmp"; but while uploading it throws "IOException = tmp is not a directory". tmp is a existing directory under /usr and i am having write permission into it.
    Please help me on this.
    Thanks in advance

    Avoid Multipost
    http://forum.java.sun.com/thread.jspa?threadID=5216365

  • Can SQL*PLUS deal with 'flat ASCII files' (input ) in UNIX ? and how?

    Can SQL*PLUS deal with 'flat ASCII files' (input ) in UNIX ? and how?

    No, but PL/SQL can. Look at utl_file.
    John Alexander www.summitsoftwaredesign.com

  • IDE /Tool which can open  a jpd file stored in UNIX  from our windows deskt

    wanted to know which IDE /Tool can open a jpd file stored in UNIX from windows desktop

    Hi Antônio G,
    Based on your description, I’m afraid that it is not the correct forum for this issue, since this forum is to discuss:
    Visual Studio WPF/SL Designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help System, and Visual Studio Editor.
    To make this issue clearly, would you mind letting us know more information about this issue? Which language are you using? Which kind of app are you developing?
    Reference:
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/a9e1857d-dd5b-443b-8633-397aea6e7b8c/help-on-properly-handling-wmf-mmanisotropic-image-in-rtf-file-when-extracted?forum=csharpgeneral
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/5b99d331-ef56-4d60-bf12-3e3b70783376/how-to-convert-a-hex-string-save-in-a-rtf-file-into-an-image-jpg-or-bmp?forum=csharpgeneral#a9219408-f73b-4e98-a9d8-7a1e0f20cdd9
    Maybe you could select the language development forum for this kind of issue. If not, please let me know more information about it, I will help you find a more appropriate forum.
    Best Regards,
    Jack
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Java program to run a C compiled file in SHELL unix

    hi,
    i have two queries,
    1) i have a c program which i compile to get a new file,{a exe file i suppose}, i need to execute it for 2000 times. for that i need to write a java program which can run the file in SHELL unix.
    can you suggest me how to write,
    2) also my file name starts with 0001.mnp to 1989.mnp, how to get 0001 as a number and during increment it should generate as 0002 ..0038 and so on. till 1989.
    the above java program which am goin to write should just take file 0001.mnp and convert it into 0001.bns,
    and get incremented automatically till the file 1989.

    hi,
    i have two queries,
    1) i have a c program which i compile to get a new
    file,{a exe file i suppose}, i need to execute it for
    2000 times. for that i need to write a java program
    which can run the file in SHELL unix.
    can you suggest me how to write,Read this: http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
    However, you could do this all in a shell script.
    >
    2) also my file name starts with 0001.mnp to
    1989.mnp, how to get 0001 as a number and during
    increment it should generate as 0002 ..0038 and so
    on. till 1989.
    the above java program which am goin to write should
    just take file 0001.mnp and convert it into
    0001.bns,
    and get incremented automatically till the file 1989.A loop? What are you having difficulty with?
    Again, this could all be done in a shell script.

Maybe you are looking for

  • Crystal report - generate CSV file through Java interface

    Hi, I need to generate a Character Seperated File through Crystal Report 10 using Java. What constant stands for CSV Format and what value of SI_PROGID we can provide to pull the CSV format. Eg. SI_PROGID = ceProgID.EXCEL or SI_PROGID = ceProgID.PDF

  • Timescale for firmware updates Lumia 520 ?

    Can anyone explain why there is such a varience in which the same update gets released either from a phone supplier or Nokia. For example I am with O2 in the UK. I asked about the Amber upgrade and the replies varied from "what is that I've never hea

  • HT204074 how about adding a device to an ID?

    I have purchased Lion OS X and for some reason it hasn't been downloaded to my computer so I can't find it. now try to re-install it again, it shows the purchase on my account but can't re-download it or install it. when I check the ID under manage t

  • I cannot get anything to work (error -9812)

    If I click on 'buy' a pop up says, "iTunes could not connect to the Music Store. An Unknown error occured (-9812). Make sure your network connection is active and try again." Nothing happens when I click on 'iTunes music card' on the home part of iTu

  • Delete old OPS$ user

    Hi! I would like to delete old OPS$ user from system copy. What is the appropeiate SQL commando? Thank you! regards