Results 1 to 10 of 10
  1. #1
    Srihari's Avatar
    Srihari is offline Member
    Join Date
    Mar 2012
    Posts
    5
    Rep Power
    0

    Default search a file in a local system (windows-D drive)

    hi guys,

    i am new to java, i am facing some problem when searching a file in local system, my code is

    Java Code:
    import java.io.*;
    import javax.swing.*;
    import java.applet.*;
    import java.net.*;
    
    
    public class SignedApplets extends Applet{
    	/**
    	 * 
    	 */
    	private static final long serialVersionUID = 1L;
    
    	public void init(){
    		new WriteText();		
    	}
    
    	public class WriteText {
    		WriteText(){
    			try {
    				String str = "D:\\Projects\\Java\\Applets\\Experiment\\WriteToAFile\\aff-masters.zip";
    				File f = new File(str);
    				if(f.exists()){
    					JOptionPane.showMessageDialog(null,"File Exists!");
    				}
    				else{
    					JOptionPane.showMessageDialog(null,"File not there!");
    					String link = "http://www.goldcoastwebdesigns.com/dl/aff-masters.zip";
    					  try
    					  {
    						  AppletContext a = getAppletContext();
    						  URL url = new URL(link);
    						  a.showDocument(url,"_blank");
    					  }
    					  catch (MalformedURLException e){
    							System.out.println(e.getMessage());
    					  }					
    				}
    			}
    			catch(Exception x){
    				x.printStackTrace();
    			}
    		}
    	}
    }
    html
    Java Code:
    <HTML>
    <body>
    <applet code="SignedApplets.class" CODEBASE="D:\Projects\Java\Applets\Experiment\WriteToAFile" width="200" height="300">
    </applet>
    
     </body>
    </html>
    and policy
    Java Code:
    grant{
        permission java.security.AllPermission;
      };
    it is working fine when searchable file and applet(related things) are in same directory.


    suppose i wanted to search entire local drive(D) for a file. what i have to do... please help me in this scenario.


    -------
    Thanks and Regards,
    Srihari(:~

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: search a file in a local system (windows-D drive)

    What is the name of the policy file and where is it located?
    Does the java program use it?
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    Srihari's Avatar
    Srihari is offline Member
    Join Date
    Mar 2012
    Posts
    5
    Rep Power
    0

    Default Re: search a file in a local system (windows-D drive)

    Quote Originally Posted by Norm View Post
    What is the name of the policy file and where is it located?
    Does the java program use it?
    thank you for replay

    the name of the policy file is: SignedApplets.policy

    i dont know how to use it, but i am using this policy file at the time of execution in command promt
    like
    appletviewer -J-Djava.security.policy=SignedApplets.policy SignedApplets.html

    that's it, i am not doing anything else.


    ------
    Thanks & Regards,
    Srihari(:~

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: search a file in a local system (windows-D drive)

    Are you getting any errors?
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    Srihari's Avatar
    Srihari is offline Member
    Join Date
    Mar 2012
    Posts
    5
    Rep Power
    0

    Default Re: search a file in a local system (windows-D drive)

    Quote Originally Posted by Norm View Post
    Are you getting any errors?
    i am not getting errors,

    while opening SignedApplets.html in browser it's working fine(i have seen "File not there" message and "http://www.goldcoastwebdesigns.com/dl/aff-masters.zip" file downloaded when File not there), when searching the file which is in another directory of the same local Drive(D), it's unable to show the same scenario(opening SignedApplets.html in browser it has to show "File not there" message and "http://www.goldcoastwebdesigns.com/dl/aff-masters.zip" file downloaded when File not there)

    -------
    Thanks & Regards,
    Srihari(:~

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: search a file in a local system (windows-D drive)

    If there are no errors, can you explain what the problem is?
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    Srihari's Avatar
    Srihari is offline Member
    Join Date
    Mar 2012
    Posts
    5
    Rep Power
    0

    Default Re: search a file in a local system (windows-D drive)

    Quote Originally Posted by Norm View Post
    If there are no errors, can you explain what the problem is?
    for suppose i have one HTML page, at the time of page load i have to check JAR/zip file is there are not in a particular location(like C:\user\hari\applet\). if not there it has to offer download

    in the previous code all the files (like .HTML page, .class file, policy file and jar/zip file that has to be searched) is under one directory.

    at that time, HTML page in browser is working fine(it can able to offer download when JAR/zip file not found),OK it's fine for me.

    now i have to search a JAR/zip file in another directory(it unable to offer download when JAR/zip file not found).

    that's my problem.

    if you understand, please suggest me.

    ------
    Thanks & Regards,
    Srihari(:~

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: search a file in a local system (windows-D drive)

    If there is no error, what does the code not do that you want it to do?
    What is rhe relationshipbetween finding the jar file and downloading? What do you mean by downloading? Where in the posted code does it do a download?

    I guess I don't understand what you are trying to do.
    If you don't understand my response, don't ignore it, ask a question.

  9. #9
    Srihari's Avatar
    Srihari is offline Member
    Join Date
    Mar 2012
    Posts
    5
    Rep Power
    0

    Default Re: search a file in a local system (windows-D drive)

    Quote Originally Posted by Norm View Post
    If there is no error, what does the code not do that you want it to do?
    What is rhe relationshipbetween finding the jar file and downloading? What do you mean by downloading? Where in the posted code does it do a download?

    I guess I don't understand what you are trying to do.
    there is no relationship between finding the jar file and downloading. blindly i wanted to download one file when search is false.
    the above code offers user to download.


    ------
    Thanks & Regards,
    Srihari(:~

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: search a file in a local system (windows-D drive)

    Is the problem: you can not open another browser window from an applet?
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Mapping Android Device as Drive Letter in Windows
    By Glorfindel Arnatuile in forum Android
    Replies: 0
    Last Post: 03-14-2012, 05:23 AM
  2. Replies: 4
    Last Post: 10-30-2010, 10:16 AM
  3. Search File on another System
    By ankit.sinha in forum Networking
    Replies: 0
    Last Post: 10-02-2010, 12:43 PM
  4. upload file from local system to database
    By harsha.udupa2008 in forum Advanced Java
    Replies: 3
    Last Post: 09-17-2010, 08:58 AM
  5. How to read xml file located in local system using Java
    By java_kick in forum Advanced Java
    Replies: 2
    Last Post: 04-06-2009, 11:28 PM

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
  •