K
K
Katya Ivanova2022-04-17 14:44:35
Java
Katya Ivanova, 2022-04-17 14:44:35

How to download a catalog from a web server?

I want to download the contents of the directory, but I get an error - java.io.IOException: Server returned HTTP response code: 403 for URL: https://minecrafttest.ucoz.net/Download/

public static void loadFile() {
        try {
            URL url = new URL("https://minecrafttest.ucoz.net/Download/");
            URLConnection connection = url.openConnection();

            File client = new File("C:/Users/pc/Desktop/load/" + "natives");

            BufferedInputStream input = new BufferedInputStream(connection.getInputStream());
            FileOutputStream output = new FileOutputStream(client);

            byte[] buffer = new byte[4096];
            int count = 0;

            while ((count = input.read(buffer)) != -1) {
                output.write(buffer, 0, count);
            }

            output.close();

        } catch (IOException e) {
            e.printStackTrace();
        }
    }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Roo, 2022-04-17
@Kats555

No way. You are not allowed access there .

T
TheAndrey7, 2022-04-17
@TheAndrey7

Buy a normal hosting with php/mysql. The "garbage" ucoz will not suit your needs.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question