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

  • Home
  • SEARCH
  • 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 8495685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:38:28+00:00 2026-06-10T23:38:28+00:00

My Java method is connecting to a remote server via SFTP and writing a

  • 0

My Java method is connecting to a remote server via SFTP and writing a string to a text file:

String messageText = "my very long Text";
ChannelSftp channel = (com.jcraft.jsch.ChannelSftp) session.openChannel("sftp");
channel.connect();
DataOutputStream out = new DataOutputStream(channel.put(filename)); 
out.writeBytes(messageText);

While writing the messageText to the file, the method crashes most of the time after writing exactly 4355Bytes. i.e. the text file is written until a certain amount of characters/bytes is reached and then just stops, however this does not happen every time the method is executed. No exception is thrown, but the spring workflow that contains this method is crashing at this point.

The Java class with the method is packed in a jar and runs inside of OSGI on a Windows Server. The remote server is Unix-based.

I appreciate any suggestions.

Update:
As proposed by mhan, I used a buffer and it seems to have solved the problem:

BufferedOutputStream out = new BufferedOutputStream(channel.put(filename + "_"));   
out.write(messageText.getBytes());
  • 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-06-10T23:38:30+00:00Added an answer on June 10, 2026 at 11:38 pm

    As the comments suggest, put the code inside a try-catch block and catch Exception. Further suggestions that I could give;

    1) Would you like to introduce a buffer and see if that can improve the performance.

    2) Can you check if the remote file is available, before you write to it?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a Java server for remote storage (an iSCSI Target). The client
I'm working on Client-Server simulation in Java where Clients (threads) are connecting to server
I have PHPMyAdmin connecting to a remote MySQL server, using those parameters: $cfg['blowfish_secret'] =
I have an app in java that is nothing but a remote server.The remote
I have a java server app that download CSV file and parse it. The
I have a client/server application that remotely connects to a server via Java's SSLSocket.
What Java method takes an int and returns +1 or -1? The criteria for
Consider the following Java method: public static void f(int n) { if (n<=1) {
I'm using a Java method to convert the date into suitable format: private Timestamp
Is there a clean Java method for merging the points of two given overlapping

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.