Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: solaris machine /tmp folder, File.exists() cant see the existing file.

  1. #1
    Junior Member
    Join Date
    Dec 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default solaris machine /tmp folder, File.exists() cant see the existing file.

    hello to all,
    i have a code that composes millions of small files into tar archives, and therefore i decided to use the /tmp folder of my solaris machine.
    here is what i did to accomplish the mission :

    first i tried to create tar archive in /tmp and then move to the target diriectory, but when i do so, during the tar process, i can see the tar file in /tmp folder, however when i check the existence of the file in /tmp it gave me a file not found exception.. what really weird is that even it couldnt find the tar file there, it could move the tar file to destination even though the move command lines should work after the file existence check.. then i decided to check the moved file, but it couldnt find the existence of the tar file in the destination neither.

    then i tried to create the tar file right in the destination directory, but the same happens there too. even the file is there, the File.exists() returns false. can anyone suggest any solution or idea about why it happens and how i can solve this problem? thanks to all.

    below is the final code of my tryings.. :

    when it comes to the line of the method czf.take_md5(tarName), it says no such file or directory.

    public static synchronized void CreateZipFileFromSingleFolder(String folder,int CDNumber) throws Exception{
     
            CreateZipFile czf = new CreateZipFile();
     
                System.err.println(folder + " tarlaniyor...");
                Process p=null;
     
                String tarName=CDFolderInfo.getID()+"_cd_"+CDNumber + ".tar ";
                String tarFolder=CDFolderInfo.getPathRoot();
                //String komut = "tar -cf " + tarFolder+"/"+tarName+"  "+ folder;
                String komut = "tar -cf " + "/opt/dist/dist1/cdrepo/"+tarName+"  "+ folder;
                try {
                    System.err.println(komut + " komutu ile tarlama yapilacak.......");
                    p = Runtime.getRuntime().exec(komut);
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                try {
                    p.waitFor();
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                System.err.println("system exit value:  "  + p.exitValue());
                if(p.exitValue()==0)
                {
                    //System.err.println("tar file existence will be checked..");
                    File f=new File("/opt/dist/dist1/cdrepo/"+tarName);
                    boolean fileExists = FileUtils.waitFor(f, 10);
                    if(fileExists){
                        System.err.println("tar succeeded .... " + tarFolder+"/"+tarName);
                        System.err.println("tar file existence PASSED ..");
                    }else{
                        System.err.println("tar process didnt fail, but actually failed...");
                    }
                    f=null;
     
     
                    /*p2 = Runtime.getRuntime().exec("mv " + tarFolder+"/"+tarName+"  "+ "cdrepo/"+tarName);
                    p2.waitFor();
                    if(p2.exitValue()==0){
                        File f2=new File("cdrepo/"+tarName);
                        if(f2.exists())
                            System.err.println("Tar tasima succeed..");
                        f2=null;
                    }else
                        System.err.println("Tar tasima failed..");*/
     
                    try {
                            czf.take_md5("/opt/dist/dist1/cdrepo/"+tarName);
                            System.err.println("MD5 alma succeed...");
                        } catch (Exception e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
     
                    Process p1=null;
                    try {
                        p1 = Runtime.getRuntime().exec("rm -rf " + folder );
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    try {
                        p1.waitFor();
                        if(p1.exitValue()==0)
                            System.err.println("Dizin silme tamamlandı... " + folder);
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }       
                }
        }


  2. #2
    Junior Member
    Join Date
    Oct 2011
    Posts
    8
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: solaris machine /tmp folder, File.exists() cant see the existing file.

    Have your program read access in the directories? It is possible you have write permission but not read permission.

Similar Threads

  1. How can I append an existing file in Java?
    By diyaots in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: February 8th, 2012, 11:26 AM
  2. File exists or not
    By Ballister in forum Java Theory & Questions
    Replies: 2
    Last Post: January 7th, 2011, 04:38 AM
  3. How to append data to an already existing file?
    By siteregsam in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: May 3rd, 2010, 02:31 PM
  4. Loading a file in a different folder
    By tiemykim in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 15th, 2010, 08:53 AM
  5. Replies: 8
    Last Post: January 6th, 2010, 09:59 AM

Tags for this Thread