commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jon Ericson (JIRA)" <>
Subject [jira] [Commented] (NET-409) FTPClient truncates file (storeFile method)
Date Mon, 23 May 2011 18:20:47 GMT


Jon Ericson commented on NET-409:

Per your request, the following sample class demonstrates the issue.  My original description
is not entirely accurate; it is not files over 2k in size that is truncated, but instead the
file size "rounds down" to the nearest 1k and truncates the rest.

The "Declaration.txt" file used in this example is the U.S. Declaration of Independence. 
It is 7.94KB on my local drive in Windows.  On arriving at the server, it is only 7K, truncating
the last few sentences.

Truncation occurs when the commons-net-3.0.jar is used.  Changing the .jar on the class path
to use the commons-net-2.2.jar, the file is transmitted in its entirety.


package com.jericson.stuff;


public class Net_409_Demo {

   * @param args
  public static void main(String[] args) {
    String independence = getStringFromFile();
    FTPClient ftpClient = new FTPClient();
    try {
      ftpClient.login("testuser", "Testpassword");
      InputStream stream = new ByteArrayInputStream(
      ftpClient.storeFile("Independence.txt", stream);
    } catch (Exception e) {
    System.out.println("** Complete **");

  private static String getStringFromFile() {

     * The file "Declaration.txt" begins with <Declaration>, ends with
     * </Declaration> and has no line separators in between.
    try {
      BufferedReader reader = new BufferedReader(new FileReader(
      StringBuilder stringBuilder = new StringBuilder();
      return stringBuilder.toString();
    } catch (Exception e) {
    return null;


> FTPClient truncates file (storeFile method)
> -------------------------------------------
>                 Key: NET-409
>                 URL:
>             Project: Commons Net
>          Issue Type: Bug
>          Components: FTP
>    Affects Versions: 3.0
>         Environment: Windows 7/Eclipse 3.6.2
>            Reporter: Jon Ericson
> Functionality works fine on commons-net-2.2.  Error occurred after upgrading library
to commons-net-3.0 version.  Sending a file from Windows 7 to CentOS/Linux using FTPClient
storeFile method results in truncation of files over 2k in size.  Rolling back upgrade to
commons-net-2.2 version fixes problem.

This message is automatically generated by JIRA.
For more information on JIRA, see:

View raw message