import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;

public class HtmlFiles {

	public static ArrayList<String> lines = new ArrayList<String>();

	public static void createFile(String link, String path, int index) throws IOException {

		URL url = new URL(link);
		URLConnection connection = url.openConnection();
		BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
		String inputLine;

		while ((inputLine = in.readLine()) != null) {

			lines.add(inputLine);
		}
		in.close();

		Path filepath = Paths.get(path);

			if (Files.exists(filepath)) {
				path = ((path.concat("\\")).concat(Integer.toString(index)).concat(".html"));
				filepath = Paths.get(path);
				Files.write(filepath, lines, Charset.forName("UTF-8"));
			} else {

				do {
					System.out.printf("%s", "Enter valid path : ");
					path = Mainclass.inputpath.nextLine();
					filepath = Paths.get(path);
				} while (!Files.exists(filepath));

				Mainclass.path = path;
				path = ((path.concat("\\")).concat(Integer.toString(index)).concat(".html"));
				filepath = Paths.get(path);
				Files.write(filepath, lines, Charset.forName("UTF-8"));
			}

			lines.removeAll(lines);
	}
}



@@ -374,16 +374,454 @@
 ring%3E();
+%0A%09private static Path filepath;%0A%09%0A%09public static void checkPath(String path) %7B%0A%0A%09%09if (Files.exists(Paths.get(path))) %7B%0A%09%09%09File theDir = new File(path.concat(%22%5C%5CHTML_Files%22));%0A%09%09%09theDir.mkdir();%0A%09%09%09Mainclass.setPath(path.concat(%22%5C%5CHTML_Files%22));%0A%09%09%09Mainclass.setPath2(path.concat(%22%5C%5CHTML_Files%22));%0A%0A%09%09%7D else %7B%0A%0A%09%09%09System.out.printf(%22%25s%22, %22Enter valid path : %22);%0A%09%09%09path = Mainclass.getInputpath().nextLine();%0A%09%09%09checkPath(path);%0A%09%09%7D%0A%09%7D%0A%09%0A%09
 %0A%0A%09publi

create method "checkPath" for checking if path is valid