How to get  current working directory of the ftp server,in java application

Hi All,
I?m FTP?ing the file using java.net.url.
Here is the snippet of the code:
public void ftpFile()throws ChrsException
try
System.out.println("FTPing the file '"+localfile+"'");
OutputStream os = openUploadStream(targetfile);
FileInputStream is = new FileInputStream(localfile);
byte[] buf = new byte[16384];
int noOfBytesRead;
while (true)
//Read the data from the source File into buf
noOfBytesRead = is.read(buf);
if (noOfBytesRead <= 0)
break;
//Writes the data present in the buf to the target file
os.write(buf, 0, noOfBytesRead);
os.close();
is.close();
close();
System.out.println ("The file '"+localfile+"' is Sucessfully FTP'd to '"+targetfile+"'");
catch (MalformedURLException malExcp)
System.out.println ("Invalid URL. Error in FTP'ing the file: \""+localfile+"\"");
catch(IOException ioe)
System.out.println ("Error in FTP'ing the file: \""+localfile+"\"");
private OutputStream openUploadStream(String targetfile) throws MalformedURLException, IOException
URL url = null;
//Creates a URL object with FTP protocol
if (user == null)
url = new URL("ftp://" + host + "/" + targetfile + ";type=i");
else
url = new URL("ftp://" + user + ":" + password + "@" + host + "/" + targetfile + ";type=i");
urlc = url.openConnection();
//Get the OutputStream that writes to this connection.
OutputStream os = urlc.getOutputStream();
return os;
Now I need to find what the current directory is when the user logs in with username and password on to the FTP server in java.
Thanks in Advance.

as soon as user logs in he is taken to the directory
"ftproot/pub/abc".
now If I execute pwd command , is hould be able to
get to know tht user is under "ftproot/pub/abc"Three respected posters, well two plus me ;-), have just told you otherwise. The information about the current directory is (a) secure and (b) useless to the user, as he can't do anything with it. The user doesn't want to know that at all and you shouldn't try to tell him. And in any case FTP doesn't support it, again for security reasons, so you can't do it.
Just accept it.

Similar Messages

  • Can't get current working directory

    I can't figure out how to get the current directory my applet is running from. I want to loop through the currentdirectory/folderA. Below is my code:
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.lang.*;
    import javax.swing.JApplet;
    import javax.swing.*;
    import java.net.*;
    public class Refresh4 extends JApplet{     
         String curDir = System.getProperty("user.dir");
        String myFile = curDir+"/folderA";//folderA within the directory that the applet is in
        File f = new File(myFile);
        long orig;
        long upd=0;
        long comp=0;
        javax.swing.Timer timer;
        int j = 1;
         public void init(){//initial run class, runs create gui once and sets up timer
            try {
                javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
                    public void run() {
            } catch (Exception e) { }
            timer = new javax.swing.Timer(2000,taskPerformer);//runs every 2 seconds
              timer.start();//starts timer
      ActionListener taskPerformer = new ActionListener() {//called by timer every 2 seconds, executes FileReader
          public void actionPerformed(ActionEvent evt) {
               j++;
               FileReader(j);
    public void FileReader(int j){//reads all files in directory and checks their modified time/date
         File[] files = f.listFiles();
              for (int i=0;i<files.length;i++){
                   File nFile = files;
                   orig = nFile.lastModified();
                   if (orig>upd){
                        upd = orig;
              if(upd>comp){
                   comp = upd;
                   if(j>2){
                   try {
                        getAppletContext().showDocument
                        (new URL("javascript:doAlert(\""+j+"\")"));
                   catch (MalformedURLException me) { }          

    String curDir = System.getProperty("user.dir");That does get the current directory.
    However, your applet should not "need" to know this, nor rely on it. If you want to open resources (such as graphic images), those resources should be packaged with the applet (like in a jar file on the server), and the applet would get them using codebase- or classpath- based APIs -- not file system-based APIs.

  • How to get current Work Repository Name?

    Hi,
    Is there any API function to get the Name of the current Work Repository the session is running on?
    THanks

    Hi-
    As of now there is no such API in ODI but there is other API's which is used to retrieve schema/dataserver details etc.
    Hope ODI will release this API in future release. Does it help you.
    Thanks,
    Saravanan Rajavel

  • How to create a virtual directory for the Report Server

    Hi, I am new to server admin and need help with configuration.
    I would like to map a physical directory on the server so that users can use a virtual path to save report outputs in that location. For example the form will call the report with desname = 'd:\xyz\abc.pdf' and the output file will be saved in a predefined directory on the server. I know how to do it on the forms server using the orion_web.xml but not sure about the report server configuration.
    We are using rwservlet to run reports on 10G release2/Windows 2000.
    Thanks in advance,

    Virtual directories are mapped in the httpd.conf file in the Apache directory as aliases:
    Alias /xyz/ "d:\xyz\"
    You can now call the report output with
    http://server/xyz/abc.pdf

  • How to get currently running tcode inside the user exist

    Hi All,
    I want to write user exist for me22n & me23n, inside the user exist i want to check tcode whether tcode is me22n or me23n my user exist is ME_PROCESS_PO_CUST
    .please help me
    Thnx//

    Hello Gevan,
    Please check the value of sy-tcode for both transaction in debugging mode in the exit and write your code accordingly.
    case sy-tcode.
    when 'ME22N'
    *ur code
    When 'ME23N'
    *ur logic
    endcase.
    find the screen shot from debugging
    Thanks

  • Can I stop Dreamweaver CS6 from constantly polling the FTP server?

    When I work in CS6 I just work directly off the FTP server. I don't work in a large team, check in and check out is a wasted feature for us. So I have the Advanced server settings to automatically upload files when I save them. This has been working pretty well with the exception that Dreamweaver CS6 seems to constantly poll the FTP server anyway. So often times I'll go to save and it will throw out an error that it can't upload the file right now because it's currently interacting with the server.
    Inside Dreamweaver I have the FTP log tab open and it's just constantly looking at stuff on the server at random intervals. It's not downloading anything or reconnecting. I'm having no connection problems at all actually outside of this.
    I've poked through settings and I can't find anything that says something like "Stop constantly checking the FTP server, it's still there, don't worry about it..."
    Here's the error for whatever it's worth. I wouldn't even bother complaining about this except that it happens to me constantly throughout the day. If it was just once or twice I wouldn't care. The other annoying thing is that when the error occurs it does save the file locally which is pointless for my purposes also but since it flags it as saved I have to make a change in order to get it to save and upload. So a lot of times I'm just waiting for it to stop interacting with the FTP server for no good reason, adding a space, backspacing the space and then hitting save again. Seriously obnoxious, please tell me there's a setting to shut this behavior off.

    I'll tell you the real answer - because Adobe Dreamweaver's FTP integration is, and has always been, horrendous.   Here I am - working with Dreamweaver in 2013, having worked with Dreamweaver since the year 2000... yes - that is 13 years.  And 13 freaking years later I am still having the SAME Dreamweaver FTP issues since back then!!
    Like today - let me tell you my workflow. 
    Open Dreamweaver - knowing that this is going to be yet again another painful day because of the FTP situation
    Make a few changes to a single file
    Connect - it connects instantly
    Upload my file.  I'm (relatively) happy.
    Work on my file for the next 10 minutes.
    Keyboard Shortcuts to save, then upload my file.
    Window pops up - Waiting for server
    Still waiting for server
    Trys to reconnect.
    Waiting for server
    I cancel.  Disconnect... then guess what...
    Window pops up - Waiting for server.
    I close that window immediately
    Reconnect - its fine
    Upload my file immediately.
    I have to do this EVERY FREAKING TIME I need to upload a file.   It is beyond rediculous that this wasn't solved in 2002, but no - ELEVEN years after that it still behaves the same!!!!
    I know I'm not alone - just google "Dreamweaver FTP Waiting for server", or "dreamweaver ftp dropping", or anything else like that, and you'll find no end of people in pure frustration. 
    The only solution that I have found that may actually help ease the pain (doesn't solve the problem unfortuantely) this is something I just found today. 
    Go to Preferences > Site settings where you can change FTP connection option : Disconnect after x minutes idle
    I have changed that to 1 minute.  Shouldn't have to, but that's all that can be done.
    Please Adobe - start from the ground up with CS7 and completely rewrite FTP in Dreamweaver.

  • How to list the top 10 largest files in the current working directory ?

    How can I list the top 10 largest files in the current working directory in Solaris ?

    execute below....to get the large files in order.. change the <FS>
    find /<FS> -type f -size +1024 -ls | awk '{print $11, $7}' | sort -rn +1 | awk '{print $1, $2/1024/1024 "MB"}' | /bin/more

  • Although my ipod shows the number of steps, calories, and time, it no longer is saving it to the history. also when I open the history it takes me to May 2010 instead of the current date. Any ideas on how to get it to start recording the history again?

    Although my ipod shows the number of steps, calories, and time, it no longer is saving it to the history. Also when I open the history it takes me to May 2010 instead of the current date. Any ideas on how to get it to start recording the history again?

    Try:                                               
    - iOS: Not responding or does not turn on           
    - Also try DFU mode after try recovery mode
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    - If not successful and you can't fully turn the iOS device fully off, let the battery fully drain. After charging for an least an hour try the above again.
    - Try another cable                     
    - Try on another computer                                                       
    - If still not successful that usually indicates a hardware problem and an appointment at the Genius Bar of an Apple store is in order.
    Apple Retail Store - Genius Bar
    The missing apps could have been done by setting the Restrictions that can hid those apps. If the backup was made with those retrictions set the the Restrictions are also restored.
    Thus, if you get it to work restore to factory settings/new iPod, not from backup                               
    You can redownload most iTunes purchases by:        
      Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • I just need to know how you get an iTunes library off the original hard drive of a mac and onto an external hard drive and still have it work normally?

    I just need to know how you get an iTunes library off the original hard drive of an imac and onto an external hard drive and still have it work as it normally would?

    http://support.apple.com/kb/HT1449

  • How do I change my default "SAP Working Directory" to the one I wish ?

    Hello Gurus,
    How do I change my default "SAP Working Directory" to the one I wish ?
    At the moment default SAP Working Directory to set to the following directory.
    "C:\Documents and Settings\T51273\SapWorkDir"
    So, when ever I try to download a Report/Table Contents/Spool Request, SAP prompts me to save in the above SAP Working Directory, which is "C:\Documents and Settings\T51273\SapWorkDir". Ofcourse I can change the folder in the dialogue box, but I don't want to change the folder each and every time I download a report from SAP.
    I wish to change my default "SAP Working Directory" to "My Documents" Folder. So that from next time,
    if ever I try to download a Report/Table Contents/Spool Request, SAP should prompt "My Documents" Folder. That way I don't have to change the folder at the time of saving.
    Full Points are assigned for an answer that works...
    Thank You,
    Nag.

    Hello,
    A short question about transaction SO21:
    Is this a local setting, per GUI?
    Or does this affect all users?
    I have a problem opening an attachment (Mandates).
    SAP wants to save it to C:\Windows\System32\
    I see that is stated at SO21.
    If I change that to another (accessable) location, does that affect the opening of the attachment?
    Thanks!

  • How to get Current row of ViewObject in the DoDML methode

    Hi all
    I have two ViewObject EmplyesView and DeptView
    How to get Current row of ViewObject DeptView in the DoDML methode of EmplyesView

    OK, we can play this game on and on...
    I'll ask for a use case (http://en.wikipedia.org/wiki/Use_case) and you don't give any info we don't already know. After an other 10 posts we probably know what you real problem is and can give you the advice which you could have gotten in the fist place.
    So please take some time and describe the problem as if you would ask your mother for help. Tell us how the data model is build and how the VO are related. Is there any input from an user involved? Which information from the other view do you need? How do you get to the doDML method? Is there a button in the ui involved?
    Timo

  • The bottom bar on my mail has disappeared which means I can't create, reply or forward to an email. Any ideas how to get it back? Touching the screen at the bottom doesn't work!

    The bottom bar in my email seems to have disappeared which means I can't create, reply or forward any emails. Any auggestions to how to get it back? Touching the bottom of the screen doesn't work. Thanks.

    Close all apps in the Multitasking Drawer; Double Tap Home Button to open drawer, Swipe up on each app to close it. Repeat until all apps are closed, touch home screen.
    Restart phone, hold both Home and Power/Sleep buttons down at the same time, continue to hold them down until the Apple Logo appears, Release both buttons and wait for phone to restart.
    Check email app to see if bottom bar and new email icon have come back.
    If not, delete the email account in settings and then add it back in again.
    If mail still not working as it should, you may try doing a Reset All Settings reset in Settings => General => Reset => Reset All Settings.  You won't lose any data, music, apps, videos,pictures, etc.  But you will have to go back in and turn on or off any settings you changed on your phone because everything will be set back to factory defaults.

  • TS1814 I have an iPhone 3GS and was trying to restore it. Now it won't let me activate my phone and my itunes tells me I have no SIM card inserted when I do. Any ideas on how to get it working again?? I'm dying without it!

    I have an iPhone 3GS and was trying to restore it...
    Now it won't let me activate my phone and my itunes tells me I have no SIM card inserted when I do.
    Any ideas on how to get it working again?

    This means that the phone was previously hacked to carrier unlock (unauthorized unlock), and when you restored, the hack was removed and it became re-locked to its original carrier.  It will now accept a SIM card only from that carrier.
    Your only option is to contact the carrier it's locked to and enquire if they will provide authorized unlocking.  Not all carriers will unlock and those that do usually have requirements and qualifications - i.e. you have to be a current or former customer in good standing.

  • How to get current version of safari. without having safari browser?

    how to get current version of safari. without having safari browser?

    I don't understand the question. Safari is a browser.
    Can you elaborate on what your are trying to do that initiated the question? People may be able to come up with some other option that gets you working the away you want.
    When you respond, please post the version of the Mac OS and the version of Safari you currently have. Otherwise, people are guessing and the quailty of help you get plummets.

  • Could not clean working directory during the Livecycle ES 8.2.1 installation

    Hi,
    while using Adobe Livecycle Configuration Manager, I am getting the following error. How could I get around this problem?
    Failed on    'Executing merge scripts for adobe-livecycle-native-weblogic-x86_win32.ear'
    Could not clean working directory
    reg,
    Raj

    I'm posting my experiences with this error because it can hopefully help other people.  I was getting the same error during the Configure LiveCycle ES (1 of 3) screen after clicking the Configure button.  It would fail around 75% with a prompt saying error code ALC-LCM-000-000 and could not clean working directory.  The progress log would indicate the failure at executing merge scripts for adobe-livecycle-native-weblogic-x86_win32.ear.  I was installing LC ES 8.2.1 SP3 + QF 3.19 with the Forms and Output components on a Windows 2003 platform.
    Rename working dir (LC support suggestion)
    Rename c:\adobe\livecycle8.2\configurationManager\working to be like working.old.  Re-run ConfigurationManager (CM).  Didn't help since I saw the same error message.
    Clicked Configure again on and it went 100% without any problems.  The rest of the install went just fine.
    Reinstall Adobe LC ES 8.2
    I was getting the same type of error on another box, but clicking Configure wasn't getting past 75% again.
    Reboot of the box didn't help on the next attempt.
    Reinstall LC ES 8.2 worked
    Used the Add/Remove programs to remove Adobe LC ES 8.2
    Reinstalled the software with SP3 + QF 3.19.
    Ran CM again and I was able to get past this error.

Maybe you are looking for

  • MacBook Air loses connection to internet but not LAN

    Hi, I am using a MacBook Air 11" (mid-2012) running OS X Mavericks (10.9.3). I'm connecting to my home LAN via WiFi connection to a TP-Link 300M Wireless router that is setup as a switch (per instructions here http://www.tp-link.com/en/article/?faqid

  • No Video on my screen

    I connect with Lync 2013 and the other person sees 2 boxes. One box with my video and one box with their video. I see 2 blue boxes. No video. It only happens on our Dell 6420's with Win7 32-bit.  (64-bit on that model is fine) If I put Lync 2010 on i

  • Pacman -S catalyst doesn't work?

    So, I know it seems odd registering and posting on the same day, but it doesn't look like anyone is having this problem. I have a Dell Inspiron 1501, and so far it's worked like a charm, except when I try to do the above command (pacman -S catalyst f

  • Exchange 2010 RTM Analyzer giving domain prep error but version number is correct?

    I have recently inherited an Exchange 2010 Standard server environment, which appears to be running RTM and unpatched. Version: 14.0 (Build 639.21) When I run Best Practice Analyzer, it gives an error message, claiming that an unrecognized Exchange s

  • Tablespace Option not found under Storage Menu (OEM 12c Express)

    Hi Guys, Am not able to see the Tablespace option under the Storage menu in ORacle enterprise manager express 12c. Is there anything we need to configure for that? any ideas please help me? Thanks, Sunil