Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.vungueanu;
- import java.io.File;
- import java.io.IOException;
- import java.net.ServerSocket;
- import java.net.Socket;
- public class Main {
- static final int PORT = 4444;
- static File directory = null;
- static ServerSocket listener = null;
- static Socket connection = null;
- public static void main(String[] args)
- throws IOException {
- if (args.length == 0) {
- System.out.println("Usage: java FileServer <dir>\n");
- return;
- }
- directory = new File (args[0]);
- if (!directory.exists()) {
- System.out.println ("Folder doesn't exist!");
- return;
- }
- if (!directory.isDirectory()) {
- System.out.println("Not a folder!\n");
- return;
- }
- listener = new ServerSocket (PORT);
- while (true) {
- connection = listener.accept();
- new doComms (directory, connection);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment