Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6674033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:41:53+00:00 2026-05-26T03:41:53+00:00

I have the following method of copying files: public static void nioCopy(File source, File

  • 0

I have the following method of copying files:

public static void nioCopy(File source, File destination) {
    FileInputStream fis = null;
    FileOutputStream fos = null;
    FileChannel input = null;
    FileChannel output = null;
    try {
        fis = new FileInputStream(source);
        fos = new FileOutputStream(destination);

         input = fis.getChannel();
         output = fos.getChannel();

        input.transferTo(0, input.size(), output);

    } catch (FileNotFoundException ex) {
        Logger.getLogger(Utilities.class.getName()).log(Level.SEVERE, "Can't find either of input/output files.", ex);
    } catch (IOException ex) {
        Logger.getLogger(Utilities.class.getName()).log(Level.SEVERE, "Can't open either of input/output file for reading/writing", ex);
    } finally {
        try {
            fis.close();
            fos.close();
            input.close();
            output.close();
        } catch (IOException ex) {
            Logger.getLogger(Utilities.class.getName()).log(Level.SEVERE, "Error closing streams", ex);
        }

    }
}

And I’m using to copy file but sometimes I get a silent error or undefined behavior or I just don’t know how to explain it and this is what I get:

Here is my source:

-rw-r--r-- 1 nb9 team92 3.1G 2011-10-13 16:31 6443_6#5_1_6443_6#5_2.fastq.f.fq.gz

And here is the destination:

-rw-r--r-- 1 nb9 team92 2.0G 2011-10-13 16:49 6443_6#5_1_6443_6#5_2.fastq.f.fq.gz

I get no exceptions while this process is being performed and by the looks of it everything should have been successful but then when I start unpacking the file I get:

java.io.EOFException: Unexpected end of ZLIB input stream

Clearly the destination is 1 gig OFF the original mark.

The only peculiarity is that both files are on a VERY busy lustre filesystem is it possible that this is making some funny things?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:41:54+00:00Added an answer on May 26, 2026 at 3:41 am

    The fact that is truncated at 2Gb got me suspicious. I searched and it looks like an issue with nio. It could also be that the target filesystem allows max 2Gb files.

    From Java NIO: Buffers

    At present, buffer sizes are limited to 2GB (the maximum positive number that can be represented in an int. An updated planned for Java 7 will allow large buffers (with the size and indexes held as a long).

    Anyway, just to be sure:

    • Can you try to copy it on the same filesystem, if you have space?
    • Can you try with Apache Commons IO FileUtils.copyFile()? Seems they fixed this issue.
    • If you can upgrade, try with Java 7, since is out already
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following method public static void SerializeToXMLFile(Object obj,Type type, string fileName) {
I have following extension method written: static public IQueryable<OutboundPattern> ByClientID(this IQueryable<OutboundPattern> qry, int clientID)
I have following method in wcf webenabled service Public Person AddPerson(Person p); As of
I have the following method that is replacing a pound sign from the file
i have the following method in a usercontrol protected override void Render(HtmlTextWriter writer) {
I have the following method and interface: public object ProcessRules(List<IRule> rules) { foreach(IRule rule
I have the following method: static double NewtonMethodModified(Func<double, double> f, double x0, double h)
I have the following method: public object[] GetEventsByUser(DateTime start, DateTime end, string fullUrl) The
I have following simple method in my main activity. private void showMap(String name )
I have a class with the following method. public cIPLink(int paramCaseNo, int paramIPID, string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.