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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:24:57+00:00 2026-05-13T09:24:57+00:00

I found this code witch I tried and it works great but(!). I want

  • 0

I found this code witch I tried and it works great but(!). I want to store the file in a folder that I will choose and also get it from a folder that I again will chose. Since the Sender get an argument then I suppose that if I give an argument like /home/user/test.txt then that’s ok and it’ll work out fine but I don’t get how to store the file to a specific folder ( the Server part in other words ). Any ideas?

If I’m wrong about the argument please by all means correct me 😀

PS: It works just fine for the Netbeans’ default folder ( no specification of folder for the Sender or Server ).

Any help appreciated.

  • 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-13T09:24:58+00:00Added an answer on May 13, 2026 at 9:24 am

    Frankly speaking, though i feel bad about doing your homework, I am just in a good mood 🙂

    In the below code(FileReciever) i have added a new variable folder which is initalized from the first argument passed to main(). So the name of the folder you want to save the file in mus tbe passed as the first argument. The only other line I have changed is:
    File file=new File(folder, file_name);

    private String folder = "";
    public static void main(String[] args) {
    try {
      folder = args[0];
      ServerSocket listener = new ServerSocket(port);
    
      while (true) {
        FileReceiver file_rec = new FileReceiver();
        file_rec.socket = listener.accept();  
    
        new Thread(file_rec).start();
      }
    }
    catch (java.lang.Exception ex) {
      ex.printStackTrace(System.out);
    }
    

    }

    public void run() {
        try {
          InputStream in = socket.getInputStream();
    
    
      int nof_files = ByteStream.toInt(in);
    
      for (int cur_file=0;cur_file < nof_files; cur_file++) {
        String file_name = ByteStream.toString(in);
    
        File file=new File(folder, file_name);
    
        ByteStream.toFile(in, file);
      }
    }
    catch (java.lang.Exception ex) {
      ex.printStackTrace(System.out);
    }
    

    }

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

Sidebar

Related Questions

I want to protect my website against spambots with javascript. I found this code,
I found this code for alphanumeric check (Letters, numbers, spaces or underscores) but I
I found this code from here: http://www.cssportal.com/form-elements/text-box.htm But the problem is you can still
I tried using a free script that I found on the Internet but it
Hi i have problem with this code, i found it on the internet and
While reflecting with ILSpy i found this line of code in the Queue<T>.Enqueue(T item)
Working with OWASP's ESAPI, I found myself stuck at this particular line of code.
i found this code: protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); HwndSource hwndSource =
I found this code using Google. private int RandomNumber(int min, int max) { Random
i found this code at activestate, it takes a string and prints permutations of

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.