Results 1 to 1 of 1
  1. #1
    aragorn1905 is offline Member
    Join Date
    Dec 2011
    Posts
    1
    Rep Power
    0

    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.

    Java Code:
    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();
    				} 		
    			}
    	}
    Last edited by aragorn1905; 12-21-2011 at 10:26 AM.

Similar Threads

  1. Replies: 0
    Last Post: 11-12-2011, 02:26 PM
  2. Check if file exists before download
    By dman in forum Networking
    Replies: 0
    Last Post: 04-28-2011, 04:57 PM
  3. Replies: 0
    Last Post: 02-07-2011, 02:27 PM
  4. Replies: 2
    Last Post: 04-07-2009, 07:25 AM
  5. How to check whether file is exists or not
    By Java Tip in forum java.io
    Replies: 0
    Last Post: 04-05-2008, 11:13 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •