Can anyone help me in sending a file through FTP

i have written a program to transfer files or directories in zipformat through FTP.i have also installed filezella server to check whether it is working or not.i have connected to filezella server but i am not able to send file.can any one send the code for sending the file.
i have also tried the jakarta api sendfile ().but in that i don't what is mode means.
for your reference i am sending the code as far developed.
import java.io.*;
import java.util.*;
import java.util.zip.*;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import org.apache.commons.net.ftp.*;
import org.apache.commons.net.tftp.*;
class FTPTransfer
static public void main(String[]p)
FTPTransfer ob = new FTPTransfer();
// ob.Create_Zip_File(new File("outfile.zip"),new File[]{new File("c:\\trialtwo")}, false);
ob.ftpConnect();
// connecting to FTP server
public void ftpConnect()
boolean error = false;
FTPClient ftp = null;
try
int reply;
//ftp.connect("ftp.comcast.com");
ftp = new FTPClient();
ftp.connect( "localhost",21);
// ftp.login( username, password );
System.out.print("reply from FTP Server :"+ftp.getReplyString());
// After connection attempt, you should check the reply code to verify
// success.
reply = ftp.getReplyCode();
if(!FTPReply.isPositiveCompletion(reply)) {
ftp.disconnect();
System.err.println("FTP server refused connection.");
System.exit(1);
// ftp.sendFile();
// transfer files
// ftp.logout();
TFTPClient tftp = new TFTPClient();
System.out.print("before sending");
tftp.sendFile("c:\\trialtwo\\a-1.txt",1,new FileInputStream("c:\\trialtwo\\a-1.txt"),"localhost",21);
System.out.print("after sending");
catch(IOException e)
error = true;
e.printStackTrace();
finally
if(ftp.isConnected())
try
ftp.disconnect();
catch(IOException ioe)
// do nothing
System.exit(error ? 1 : 0);
//send files
// filename - The name the remote server should use when creating the file on its file system.
// mode - The TFTP mode of the transfer (one of the MODE constants).
// host - The remote host receiving the file.
//port - The port number of the remote TFTP server.
private void listContents( File Zip_File, File dir, ZipOutputStream out )
throws Exception
String[] files;
files = dir.list();
byte[] buf = new byte[1024];
File[] file = dir.listFiles();
for (int i = 0; i < file.length; i++) {
System.out.println("*********** "+file);
// File f = new File(dir,file[i]);
try{
FileInputStream in = new FileInputStream(file[i]);
out.putNextEntry(new ZipEntry(file[i].getPath()));
int len;
while((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
in.close();
catch(Exception e)
zipEntry(Zip_File, file[i], out);
} // end listContents()
void Create_Zip_File(File Zip_File,File[] To_Be_Zipped_Files,boolean Skip_Dirs)
try
// Open archive file
FileOutputStream stream=new FileOutputStream(Zip_File);
ZipOutputStream out=new ZipOutputStream(stream);
for (int i=0;i<To_Be_Zipped_Files.length;i++)
//if (To_Be_Zipped_Files[i]==null
// || !To_Be_Zipped_Files[i].exists()
// || (Skip_Dirs ))
// continue;
System.out.println("Adding "+To_Be_Zipped_Files[i].getName());
zipEntry(Zip_File, To_Be_Zipped_Files[i], out);
out.close();
stream.close();
System.out.println("Finished zipping : "+ Zip_File.getAbsolutePath());
catch (Exception e)
e.printStackTrace();
System.out.println("Error: " + e.getMessage());
return;
private void zipEntry(File Zip_File, File file, ZipOutputStream out) throws Exception
if (file.isDirectory())
listContents(Zip_File, file, out);
return;

You'll stand a better chance of getting help if you're more specific about what problems you're encountering. "Can't send file" doesn't say much.
When you post code, please use[code] and [/code] tags as described in Formatting tips on the message entry page. It makes it much easier to read.

Similar Messages

  • Can anyone help me to change the file to version 8.6 ??

    can anyone help me to change the file to version 8.6 ??
    Attachments:
    Hydrostatic_Test.vi ‏2362 KB

    Duplicate Post.
    http://forums.ni.com/ni/board/message?board.id=170&thread.id=465548
    Tim
    Johnson Controls
    Holland Michigan

  • Can anyone help me decompile a class file?

    Can anyone pls help me decompile a class file? I've used DJ decompiler and Cavaj decompiler to decompile it but both can't seem to decompile it successfully. How do I attach the class file here? Thanks in advance!

    Oh! Now I get it. So sorry I didnt intend for anybody
    to do something illegal/unethical. I dont know much
    about Java programming since I am very new to this
    language. I didnt know anything about obfuscating
    codes either. The reason why I was trying to
    decompile the said class file is because I wanted to
    check whether the hack program I downloaded ...That is completely contradictory.
    By the way, can you tell me how I can learn Jave programming
    without the aid of a book since I couldnt find one
    yet.Given the eleventy bachillionty kathousand books that exist on java programming, something tells me you haven't looked too hard for one.
    The best non-hard-copy source:
    www.google.com

  • Can anyone help me with retreiving datalog files?

    I have been working to find a way to read an analog input signal as a waveform, and then attempting to save the data (as just the raw data--like ordered pairs) to a file. Obviously, I would like to be able to read this data later on, but I have been unable to do so as of yet. I have been working with saving the data as datalog files. I am attaching both my read and write file VI's, and I wonder if anyone may be able to tell me what is going wrong. The problem seems to be with the read file. The write file generates a file, but when I try to read this file, the read file does not recognize it as a valid datalog file and will not read it. My programs are very similar to those in ....\examples\file\datal
    og.llb, but I have not been able to actually read the files I create. I hope I have been clear enough in describing my problem. Thank you for any help you can offer.
    Jonathan
    Attachments:
    Write_Data3.vi ‏35 KB
    Read_Data2.vi ‏26 KB

    Hi Johnathan,
    Please be patient with us.
    Most of the people answering questions on this exchange do so on a voluntary basis. We do so because we want to help.
    Dennis has done a wonderful job of carrying the bulk of this exchange's traffic.
    He has answered almost 900 questions in the last two years.
    He merits a major award if you ask me. Maybe a "leg lamp" he can display in his front window.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Can anyone help me open these InDesign files?

    I've been trying all day to open files for a project I was working on in March with InDesign.  I could open them in March but now my computer is either crashing from trying to load the folder that contains the files, or it gives me one of two error messages.  The first saying I don't have permission to open the file, the second saying the file is already open with another user.
    I have tried opening from my computer and from an external drive, neither work.  I have tried restarting.  I've tried opening as a copy, original and normal.  I've tried opening InDesign as an administrator.  I have tried phoning Adobe and have been on hold for 25 minutes so far.  I have tried the online help but nobody available there.  I don't know what else to try.
    I can create a new InDesign files and I'm not having any trouble with any other Adobe products.  My subscription is until 29th August.  Any ideas appreciated.
    Thanks,
    Angs

    If you open it in a plain text editor, what do the first few lines look like? If there's no lock file, the next most likely cause for this error is that the files aren't really .indd files.

  • Can anyone help me rewrite a .bat file to work on my iMac?

    I need some help writing these .bat files so i can use them on my mac
    @echo off
    @title Dump
    set CLASSPATH=.;dist\Lithium.jar;dist\mina-core.jar;dist\slf4j-api.jar;dist\slf4j-j dk14.jar;dist\mysql-connector-java-bin.jar
    java -server -Dnet.sf.odinms.wzpath=wz/ tools.wztosql.DumpItems
    pause
    //new file
    @echo off
    @title Dump
    set CLASSPATH=.;dist\Lithium.jar;dist\mina-core.jar;dist\slf4j-api.jar;dist\slf4j-j dk14.jar;dist\mysql-connector-java-bin.jar;dist\bcprov-jdk16-145.jar
    java -server -Dnet.sf.odinms.wzpath=wz/ tools.wztosql.DumpMobSkills
    pause
    //new file
    @echo off
    @title Dump
    set CLASSPATH=.;dist\Lithium.jar;dist\mina-core.jar;dist\slf4j-api.jar;dist\slf4j-j dk14.jar;dist\mysql-connector-java-bin.jar;dist\bcprov-jdk16-145.jar
    java -server -Dnet.sf.odinms.wzpath=wz/ tools.wztosql.DumpQuests
    pause
    //new file
    @echo off
    @title Lithium Server Console
    set CLASSPATH=.;dist\Lithium.jar;dist\mina-core.jar;dist\slf4j-api.jar;dist\slf4j-j dk14.jar;dist\mysql-connector-java-bin.jar
    java -server -Dnet.sf.odinms.wzpath=wz/ server.Start
    pause
    Thank you very much, im sorry if i seem very ignorant by asking this, i just dont know applescript and im trying to get this done as fast as possible.

    Try the developer forums:
    https://discussions.apple.com/community/developer_forums

  • Can anyone help to download a little file from support portal!!!

    HI all!
    please help me!
    I have Netweaver SR3 + PI, i need to import fie (xi content in Integration Builder) for solving tasks////
    i have an access to support portal, but this file (SAPBASIS70018_0-20000888.ZIP) can download only by SolMan, a don't have it,........
    Anybody if have this file or can download it,please help me
    the path:// service.sap.com/swdc -> Download -> Support Packages and Patches -> Entry by Application Group -> SAP Content -> ESR Content (XI Content) ->
    This file SAPBASIS70017_0-20000888.ZIP or SAPBASIS70018_0-20000888.ZIP

    I opened my e-mail adresss/
    i need  XI CONTENT SAP_BASIS 7.00 for SAP Netweaver SR3
    Artyom Suchkov
    thanks.

  • Can anyone help my set up my email through 1 and 1?

    I cant set up my business email although my personal email wasn not a problem.. My company uses 1and1 webmail.  Any help!

    Set up your email in...? An email client of some sort, I assume. Have you tried with the settings 1&1 recommends? If those don't work, can you give us the error you are getting so we can have a better idea of what exactly the problem is?
    If a forum member gives an answer you like, give them the Kudos they deserve. If a member gives you the answer to your question, mark the answer as Accepted Solution so others can see the solution to the problem.
    "All knowledge is worth having."

  • Since updating my Iphone 4 I cannot figure out how to delete old messages.  There is no edit button.  Can anyone help?

    Since updating my Iphone 4 I cannot figure out how to delete old messages.  There is no edit button.  Can anyone help?

    By "sending" do you mean sending email?
    If so, what app are you using to take the photos on your iPhone 5? Or are the photos from a different source (saved to your Camera Roll from somewhere else, like a web page or Messages)?
    My guess is that Mail gives you the option to send different file sizes when it detects you are trying to Mail a really large photo file. The size of photos on the iPhone 5 is really big and some email providers may stop your mail from being delivered if attachments are too large. Thus, Mail tries to help you by offering to resize the photo.
    I suspect that if you are sending smaller files, Mail does not bother giving you options to save a smaller version. In fact, I have seen this behavior. So, if the photo is already "small enough", it gets sent as-is.
    To my  knowledge, there is no global iOS setting for this. Some apps may have different rules, of course.

  • Imnot sure if I am in the right please for this..I have OSX 10.9 ..I produce  weekly invoice in numbers which I export to Exel . Since recent updates I find that the file extn is now XLSX and when I open it the cumber content has changed! Can anyone help

    I use 'numbers" to create an invoice which I previously exported(prior to recent updating) to Exel to enable me to send it to my employer. When I try to do this now I get an file extn XLSX and the number content I placed on the invoice is different ( as if the file is corrupted)...can anyone help please ?

    I use 'numbers" to create an invoice which I previously exported(prior to recent updating) to Exel to enable me to send it to my employer. When I try to do this now I get an file extn XLSX and the number content I placed on the invoice is different ( as if the file is corrupted)...can anyone help please ?

  • Can anyone help? Need to collect 4 or more pdf-files into one file

    Hi,
    I regurarly need to mail pdf-files. I'm searching an app or program that can collect 4 or more different pdf-files into one file. So I don't need to send them all apart.
    Can anyone help me out?
    Thanx!
    Theo

    Open Preview, open the PDFs you want to combine, select View/Show Thumbnail, drag the PDFs, you want to combine to the first PDF, then Export as PDF.
    Preview Help

  • I recently had to update to office 2011 and outlook. All went well but now I cannot send via outlook but apple mail works ok and outlook receive is working. Can anyone help?

    I mac 24in 2.8 4gb ram OS 10.10
    I recently had to update to os10.10 and consequently office 2011 with outlook.  All was going well with the outlook mail until yesterday when the outlook send mail stopped working, receive works ok. I get error code 3259 and the message "an operation on the server timed out. the server may be down, overloaded, or there may be too much net traffic."  In the details  "Mail could not be sent.  Account name: "[email protected]"  The send failure occurs on my yahoo accounts, gmail accounts and comcast accounts.  Both send and receive work ok on apple mail.  Can anyone help me sort this and avoid going to microsoft support?

    hi i had the same problem today when i updated my itunes to latest version. however, i have just found my songs in the 'itunes media' folder. this was accessed through 'my music'  then keep clicking through until you find itunes media and all my library songs were in there and i then just added these files to my library and all were restored however, i have lost all my playlists but at least my 700 songs are back. very dissapointed with apple that they have let this happen with their latest update, the previous version was miles better than this one . hope you find them. stevo

  • I can't send emails from iPhone until I connect to my wifi! I am with bigpond and have a bigpond email address. Can anyone help me?

    I can't send emails from iPhone until I connect to my wifi at home. I am with bigpond and have a bigpond email address. Can anyone help me?

    Try closing the Mail app completely and see if it works properly when you re-open it : from the home screen (i.e. not with the Mail app 'open' on-screen) double-click the home button to bring up the taskbar, then press and hold any of the apps on the taskbar for a couple of seconds or so until they start shaking, then press the '-' in the top left of the Mail app to close it, and touch any part of the screen above the taskbar so as to stop the shaking and close the taskbar.
    If that doesn't work then try a reset : press and hold both the sleep and home buttons for about 10 to 15 seconds (ignore the red slider), after which the Apple logo should appear - you won't lose any content, it's the iPad equivalent of a reboot.

  • TS3276 I cannot connect to my outgoing email server on my macBook pro, yet I can, for the same email account on my iPad. Also I can send emails from the other email account I have on my MacBook...really confused can anyone help?

    I cannot connect to my outgoing email server on my macBook pro, yet I can, for the same email account on my iPad. Also I can send emails from the other email account I have on my MacBook...really confused can anyone help?

    Sometimes deleting the account and then re-creating it can solve this issue
    Write down all the information in accounts before doing this
    Highlight the account on the left and click the minus button
    Then click the plus button to add the new account and follow the prompts

  • Apple iPad 3. BT email not working. Cannot send emails from btconnect SMTP after iOS upgrade. This is the only difference I am aware of. Can anyone help me please.

    BT email not working. Cannot send emails from btconnect SMTP after iOS upgrade. This is the only difference I am aware of. Apple iPad 3. Can anyone help me please.

    All resolved at last
    Deleted the SMTP setting
    Recreated the SMTP using the same settings
    Able to send emails now
    No logic - as usual - just a bug!

Maybe you are looking for