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 1108189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:02:38+00:00 2026-05-17T02:02:38+00:00

I am currently working on a homework assignment and I am thoroughly stuck. I

  • 0

I am currently working on a homework assignment and I am thoroughly stuck. I am on the last question and I just can not figure out how to go about accomplishing the last task. Below is the tasks I had to complete:


  1. The client should
    save the file in the “client”
    subdirectory of the home directory.

  2. Test your program. Be sure it works
    with binary files, not just text
    files. Be sure it works when both
    programs are on the same machine as
    well as when they are separated over
    the network.


Thus far when I start the server it asks what port I want to use. Then I start the client and it asks what IP and port to use. The the server immediately sends a list of the files in the home directory “server” folder. I then respond with the client with the file number I wish to download. This is where I get stuck. I can’t seem to find any information about how to do this. So as you can see in my code posted below, I am trying to use a FileInputReader to convert the file to an array of bytes. Then I am sending that to the client. I am then trying to FileOutputReader the recieved array of bytes to a file. But I can’t seem to find the correct methods to do that, or even if I am doing that correctly.

CLIENT

        int i = 0;
        while(i < 1000){
        String modifiedSentence = inFromServer.readLine();
        System.out.println("From Server: " + modifiedSentence);
        i++;
        }

        while(j < 1000) {
        int byteString = inFromServer.read();
        ArrayList<byte[]> bytes = new ArrayList<byte[]>();
        bytes.add(byteString);
        }
        Integer byteInt = new Integer(byteString);
        FileOutputStream fo = new FileOutputStream(System.getProperty("user.home")+ "/client/text.txt");
        fo.write(byteInt.byteValue());

    }
}

SERVER

            byte[] bytes = new byte[1024];
            FileInputStream fi = new FileInputStream(file.toString() + fileArray[userChoiceInt]);
            fi.read(bytes, 0, 1024);
            outToClient.write(bytes, 0, 1024);

        }
    }
}

If anyone could offer any advice or the correct classes or methods to use I would appreciate it.

Thank you in advance.

  • 1 1 Answer
  • 1 View
  • 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-17T02:02:39+00:00Added an answer on May 17, 2026 at 2:02 am

    Without spoiling the whole thing here’s some hints.

    This can be easily accomplish by using Socket (Server & Client). Using byte[] for transfering the file(s) will ensure that your program will work with both ascii and binary file(s).

    Another approach would be to use the build in Remote Method Invocation (RMI). I haven’t transfered file using this approach but I’m sure it’s feasible.

    And in case you didn’t know, getting the user home directory is accomplished with the following call: System.getProperty( “user.home” );

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

Sidebar

Related Questions

I have a homework assignment. I'm not looking for anyone to do the work
This is a school-related question, although not exactly homework. I'm taking an algorithms course,
G'day guys, Trying currently to finish up a bit of homework I'm working on,
I currently working on an issue tracker for my company to help them keep
I am currently working on a project and my goal is to locate text
I'm currently working on creating a new C# project that needs to interact with
I am currently working on a project with specific requirements. A brief overview of
The system I am currently working on requires some role-based security, which is well
I'm currently working at a small web development company, we mostly do campaign sites
The company I'm currently working for is using Selenium for Uniting-Testing our User Interface.

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.