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 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 am currently working on a homework assignment where I have to create a
I'm currently working on a homework assignment where I need to set up a
I am currently working on a homework assignment to generate what is known as
The Background I am currently working on small MIPS program for a homework assignment,
I`m currently working out the design for simple graphic editor, who support trivial operations
I'm working on a homework assignment for CS1, it's supposed to bring us back
This is homework...I'm not asking for answers, I just have a bug I'm not
G'day guys, Trying currently to finish up a bit of homework I'm working on,
My homework question given is: How can you print the path of the current
I'm currently working on the following homework: CREATE TABLE T_1 (COURSE_NO CHAR(8) PRIMARY KEY,

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.