How to declare ftp in File class. I want to display filename of file in FTP

How to declare ftp in File class. I want to display filename of file in FTP server.
I try
File f2= new File("ftp://abc:abc1111@ABC/file");
               String n[] = f2.list();
               System.out.print(n[0]);
               Vector filename = null ;
               for (int i2 = 0; i2 < n.length; i2++) {
                    filename.add(n[i2]);
but it is not work
Thank you.

You can use Jakarta's net-package to connect to a FTP server.
Download it here:
http://jakarta.apache.org/site/downloads/downloads_commons-net.cgi
Here's a small demo:
import org.apache.commons.net.ftp.*;
public class FTPTest {
    private boolean isConnected;
    private FTPClient client;
    public FTPTest() {
        isConnected = false;
        connect();
    private void connect() {
        String server = "server.org";
        String username = "user";
        String password = "password";
        client = new FTPClient();
        try {
            client.connect(server);
            client.login(username, password);
            String[] files = client.listNames();
            for(int i = 0; i < files.length; i++) {
                System.out.println(files);
isConnected = true;
disconnect();
catch(Exception e) {
e.printStackTrace();
private void disconnect() {
if(isConnected) {
try {
client.disconnect();
isConnected = false;
catch(Exception e) {
e.printStackTrace();
public static void main(String[] args) {
new FTPTest();

Similar Messages

  • I have few PDf files on my computer and I want to add them to my ipod touch, please tell me the procedure on how should I do that? Secondly I want to run these Pdf files through the ibook app, as it also have the Pdf file sections

    I have few PDf files on my computer and I want to add them to my ipod touch, please tell me the procedure on how should I do that? Secondly I want to run these Pdf files through the ibook app, as it also have the Pdf file sections

    You should be able to just place them in your Books library in iTunes and check to ensure that your Book library is configured to sync to your iPod when you sync your iPod to iTunes.

  • I want to display a HTML file that is stored locally on my machine.

    Hello,
    I am having a problem with my paths (I believe). I have created a JEditorPane that reads in a HTLM page. If the page is form the web it works fine:
    page_jep.setPage("http://www.google.com");However I want to display a HTML file that is stored locally on my machine.
    I have tried the following but cant get it to find the stored page:
    page_jep.setPage("file:///index.htm");
    java.io.FileNotFoundException: \index.htm (The system cannot find the file specified)I have tried putting the index file in both the root directory ( C ) and also the same place as where the class files are.
    Any help will be gratefully received,
    Harold Clements

    Nope, I have tried it:
    page_jep.setPage("file://c:\\index.htm");Gives me:
    java.net.UnknownHostException: c

  • I want to display a video file on Flash without ENCODING IT! HELP ME PLEASE

    Hi everyone! I am using Macromedia Flash 8 and now I want to
    display a video file (avi formatted, for example) on flash . But
    the main idea is that I don't want to encode this file into *.flv
    file, I want to display it directly. Please, any one , can you help
    me to find a solution?!
    thanks very much

    Nope, I have tried it:
    page_jep.setPage("file://c:\\index.htm");Gives me:
    java.net.UnknownHostException: c

  • How to declare interface within a class

    1. I want to declare interface within a class. How can i do that & whats the advantage ?
    2. How to declare class within a interface ?
    Can anybody tell me the concept ?/
    Thanks in advance
    madhu

    Classes and interfaces are types.
    What is the advantage of declaring a type within another one?
    Do you know what is the advantage of declaring a class within another class?

  • How to specify the directory in which we want to store the uploaded files

    Hello !!
    I am using apache commonfile upload for uploading my files.I followed the user guide and tried to run a program,but my problem is I am not able to understand as to how to mention the directory in which the uploaded file will be saved..My code is given below :
    package r;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import org.apache.commons.fileupload.*;
    import org.apache.commons.fileupload.servlet.*;
    import org.apache.commons.fileupload.disk.*;
    import org.apache.commons.io.*;
    import java.lang.Exception;
    public class fileupload extends HttpServlet
         public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException
                   // Check that we have a file upload request
                  boolean isMultipart = ServletFileUpload.isMultipartContent(request);
                 System.out.println(isMultipart);
                 if (ServletFileUpload.isMultipartContent(request))
                 // Create a factory for disk-based file items
                   FileItemFactory factory = new DiskFileItemFactory();
                   // Create a new file upload handler
                   ServletFileUpload upload = new ServletFileUpload(factory);
                   // Parse the request
                   try {
                               List items= upload.parseRequest(request);               
                             Iterator iter = items.iterator();
                             while (iter.hasNext())
                                   FileItem item = (FileItem) iter.next();                    
                                 if (item.isFormField()) //NORMAL FORM FIELD
                                 String name = item.getFieldName();
                                  String value = item.getString();
                                  System.out.println(value);                                                             
                                  else
                                 String fileName = item.getName();
                                 System.out.println(fileName);
                                    String contentType = item.getContentType();
                                  File saveTo = new File("/info/upload_files/myFile.jpeg");
                             try
                                       item.write(saveTo);
                                       System.out.println("File written" );                    
                             catch(Exception e)
                                         System.out.println("File not written");
                                   // InputStream fs= item.getInputStream();                    
                                   fileName = FilenameUtils.getName(fileName);
                                    System.out.println(fileName);
                        }//end of try
              catch (Exception e) { }
         public void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException
                 doGet(request,response);
    The problem is that the control doesn't reach the try statement and I get " File not written" on the console because it enters catch everytime..Please tell me how the path to the directory should be given...Rest of the code is working fine

    No, the problem is that when an Exception is thrown, you ignore it completely and throw away all the information associated with it. That leaves you to guess at what the problem is. So instead of answering your guess at a good question, I'm going to suggest that in all of your catch blocks you put this code:e.printStackTrace();Then you can look at the output in the log file and see what the problem is. Start from there.

  • Want to display a .bmp file in reports

    Hello there
    I am trying to display a .bmp file on reports which I think is simple.the main problem is that After making changes to report we transfer the report file to Unix and then generate the report in unix and print it and in that process the report stops printing.
    Thanks in advance.
    Jha

    make sure SOURCE FILENAME is valid in your LINK FILE pointing to the image.bmp
    Report compiles nicely even with wrong source filename, only when opening layout editor an error message will appear.

  • How to declare a custome AS-class that extend a Flex componenet

    Hello there, would you please help. I have the following mxml tag
    <mx:Application xmlns:mx="xmlns:fx="http://ns.adobe.com/mxml/2009"xmlns:custom="com.myComponents.*" layout="absolute" />
    <custom:ReturnData id="dataR" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true" />
    <fx:Declarations>
    <s:CallResponder id="getAllResult"/>
    </fx:Declarations>
    When I change this into AS and try to use the result in a dataGrid, no info will be populated in datagrid, any idea??? It works when use the xmlns tag.
    2) as actionscript object
    <fx:Script>
         <![CDATA[
              import com.myComponents.*;
              public var dataR:ReturnData;
              getAllResult.token = dataR.getAll();
         ]]>
    </fx:Script>
    <mx:DataGrid x="10" y="21" id="dataGrid" creationComplete="dataGrid_creationCompleteHandler(event)" dataProvider="{getAllResult.lastResult}">
    <mx:columns>
    <mx:DataGridColumn headerText="TreatmentareaID" dataField="TreatmentareaID"/>
    <mx:DataGridColumn headerText="ProductName" dataField="ProductName"/>
    </mx:columns></mx:DataGrid>I

    Thanks for your feedback, my original code is as here below. DataGrid2 populate the data since the component has been initialized in the xmlns. DataGrid does not populate the data and has been initialized by ActionScript???
    Any idea where do I do wrong?
    Thanks
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
       xmlns:s="library://ns.adobe.com/flex/spark"
       xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" initialize="application1_initializeHandler(event)" minHeight="600"  xmlns:productrestylaneservice="services.productrestylaneservice.*">
    <fx:Script>
    <![CDATA[
    import mx.controls.Alert;
    import mx.events.FlexEvent;
    import services.productrestylaneservice.*;
    [Bindalbe]public var productRestylaneService:ProductRestylaneService;
    protected function dataGrid_creationCompleteHandler(event:FlexEvent):void
    getAllTreatmentAreaRestylaneResult.token = productRestylaneService.getAllTreatmentAreaRestylane();
    protected function application1_initializeHandler(event:FlexEvent):void
    getAllTreatmentAreaRestylaneResult.token = productRestylaneService.getAllTreatmentAreaRestylane();
    protected function dataGrid2_creationCompleteHandler(event:FlexEvent):void
    getAllTreatmentAreaRestylaneResult2.token = productRestylaneService2.getAllTreatmentAreaRestylane();
    ]]>
    </fx:Script>
    <fx:Declarations>
    <s:CallResponder id="getAllTreatmentAreaRestylaneResult"/>
    <s:CallResponder id="getAllTreatmentAreaRestylaneResult2"/>
    <productrestylaneservice:ProductRestylaneService id="productRestylaneService2" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <mx:DataGrid x="10" y="21" id="dataGrid" creationComplete="dataGrid_creationCompleteHandler(event)" dataProvider="{getAllTreatmentAreaRestylaneResult.lastResult}">
    <mx:columns>
    <mx:DataGridColumn headerText="TreatmentareaID" dataField="TreatmentareaID"/>
    <mx:DataGridColumn headerText="ProductName" dataField="ProductName"/>
    </mx:columns>
    </mx:DataGrid>
    <mx:DataGrid x="462" y="21" id="dataGrid2" creationComplete="dataGrid2_creationCompleteHandler(event)" dataProvider="{getAllTreatmentAreaRestylaneResult2.lastResult}">
    <mx:columns>
    <mx:DataGridColumn headerText="TreatmentareaID" dataField="TreatmentareaID"/>
    <mx:DataGridColumn headerText="ProductName" dataField="ProductName"/>
    </mx:columns>
    </mx:DataGrid>
    </s:Application>

  • File to RFC want to delay rfc or file adapter

    Hi,
    I’ve got a problem with my file to RFC scenario.
    XI picks up a file and puts it to an archive directory.
    Then it makes a synchoon call to a RFC. Quality of Service is Best Effort
    The problem is, that the function module does not execute properly, because it can not find the file, so the RFC acts to quick.
    When I change the quality of service to Exactly One or Exactly One in Order it works properly but in that cause I can not see my return message in the payload from SXMB_MONI.
    I guess it is not possible to delay the RFC with the help of additional parameters. The only way to handle this I think is to build a wait function into the function module but my opinion, that's not a correct solution.
    Any expert an idea?
    Thanks in advance for your answers!

    Hi,
    File adapter doesnot support Sychronous. It only supports Asynchronous. Even you specify as synchrounous it acts like asynchronous only. So that is the reason why you are not seeing the response message in SXMB_MONI.
    ---Satish

  • I have iMovie '11, and I am unable to access mpeg HD video files that I want to edit.  The files are fine (I can open and watch them using VLC), but I cannot seem to import the files into iMovie. File Import does not work.  Any suggestions??

    More detail: I have a bunch of mpeg HD video files that were shot on a SONY HDR-HC3 Handycam camcorder.  I would like to edit these into a single video production.  I can access and view the mpeg files using VLC (Quicktime does not work with them).  However, I seem to be unable to get the mpeg files to interface with iMovie '11 -- I cannot use the File --> Import command, nor can I drag-and-drop them into iMovie.
    Is there something anyone might suggest to get this to work?  Or are these files incompatible with iMovie?  If so, I assume I must purchase a different video editing software program (e.g. Adobe Premeir Pro).  Suggestions???
    Many thanks in advance for your time and consideration

      Yes, I tried that.   The files were ordered by their original numbers as imported from the camera, but I batched them through Phocoshop to downsize all of them into a more manageable file size.   I opened that destination folder from quick time  from where it said select image sequence.   I clicked on the first one and opened it.   The result was a large image with an arrow indicating a movie was ready to go.   When I pressed the arrow, though, I realized it had only imported that one frame so there was no movie.   The files are Jpgs and are about 450 KB each. 
        To your knowledge are there any links to iMovie tutorials or quick time tutorials that may address this situation?  Maybe there will be one I haven't looked at yet. 
        Thanks

  • How to get only error message which i want to display.

    hello,
    In my main system i am using power supply which is connected with different instruments like data logger ,GSM,GPS....
    In my main vi all the subvi of power system ,gsm etc...are conected with each other.
    now I want to make some changes,
    for example when i run my vi then it should seems pop up msg like Make sure your power supply is on.
    and if suppose its not on then display the pop up msg that your power supply is off, then system should be off,means no need to do further operation.
    here i attach my vi in that i made some logic regarding to this,in that when i run my main vi i get msg for make sure that power supply is on.
    but when power supply is off then i got error msg like your power supply is off and after cliking on ok error vi is open that i dont want,that all i attached here.
    i only want msg that your power supply is off and then system should be off,nothing more.
    will you please guide me that what king of changes i needed for that.
    thank you very much in advance.
    Solved!
    Go to Solution.
    Attachments:
    HMP POWER ON.vi ‏18 KB
    1.png ‏156 KB
    2.png ‏178 KB

    There's no need for the while loops.  What you really want is a case structure from the error cluster in order to decide whether or not to show the error dialog.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    HMP POWER ON_BD.png ‏22 KB

  • How to know which class is being loaded from which jar file & path location

    Hi,
    I have some Java code using several jar files.
    I want to remove those jar files which are not being used by the code.
    So , I want the JVM to output which class is being loaded from which jar .
    Using "java -verbose" option doesnt solve the problem because the required info is printed only for the classes/jars native to the J2SE package .
    Can anyone provide a solution which does not require me to modify the code?
    Thanks,
    Danish

    Classpath Helper

  • How to display 4Gb ECW file in mapviewer?

    Hi,
    I have a 4Gb ECW format file which i want to display in mapviewer. I do not know how to start, i read the chapter 'Creating and Registering a Custom Image Renderer' from the Oracle Application Server MapViewer User's Guide but in my understanding it gives two problems for my situation:
    - the example has ecw files in the database, i have a 4Gb file which probably will not be very wise to put in a blob column?
    - we run on linux and ECW SDK which is used by the example only runs on Sun and Windows?
    So basically, what options do i have to render a 4Gb ECW format arial foto with Oracle Mapviewer?
    Kind Regards,
    Andre Jochems

    Hi Andre,
    to render images with a specific format (GIF, JPEG, ...) in MapViewer you need to store the images using a BLOB column. The example with the ECW is just to show how to implement a custom rendering for a specific image format. This post has some additonal implementations for the ECW case:
    Re: Mapviewer ECWRenderer Help!!
    About the SDK, you will need to investigate if there is any available for linux.
    Joao

  • How to display thumbnail of files????

    i want to display my avi file list in thumbnail view as windows explorer is providing... can anyone tell me... how can i implement the same??

    Cross post: http://forum.java.sun.com/thread.jspa?threadID=646758

  • Transfering Files from one computer to another over the internet using ftp

    I am not sure if this is the right section to post this question but i wanted to know if it was possible to use the mac ftp file sharing to transfer a file from a friends computer to mine. He is not on my network we were hoping to transfer the file over the internet the file is quite larger about 2gb. Can any one help me in telling me a way that i could do this thanks.

    Enable FTP in Preferences on the target machine.
    You will need the IP address...
    You can find it by going here
    http://whatismyip.com/
    This may be a problem if the target machine is behind a router.
    If all goes well... Go to Connect to Server.. and enter
    ftp://ipaddress
    OR
    If you want to send a large file then you can check this out...
    www.yousendit.com/

Maybe you are looking for

  • Option "ctrl:nocaps" in /etc/X11/xorg.conf.d/10-evdev.conf ignored

    Hi all, I have a single-user laptop, so I'd like to configure my X keyboard layout and options globally instead of doing it for any WM/DE I might happen to use.  And most importantly, the desktop manager (GDM) should already use my layout.  So my /et

  • Can PPC and Intel OS's be on the same hard drive?

    I do a lot of work on Apple computers for clients. I have made it a habit to bring firewire hard drives with OS X installed to my work locations so I can boot peoples' computers from my own, clean OS for numerous troubleshooting purposes. I was hopin

  • Using Migration Assistant to restore after hard drive failure?

    My MacBook's hard drive recently went kaput. The replacement arrived today and I attempted to do a TM restore when booting from the Snow Leopard disc. However, it inccorrectly states "This disk does not have enough space to restore your system." The

  • Unable to connect: incorrect log on parameters. Database Vendor Code: 18456

    I have imported a report into Info View (that has no parameters), I am able to run the report on Demand in InfoView, and I am also able to run the report within the CMC Preview.   I have tried scheduling using the admin account in CMC, through the pu

  • Export JTable Column headers to Excel document

    Hello all!!! I am having a small problem while trying to export some data from a jTable to an excel document. I have a jTable and I use a custom TableModel with this: private String[] columnNames = {"First", "Second", "Third", "Forth"};as names for e