public void downloadTextFile(URL url) throws IOException {
  
        String fileName = null;
        File tempFile = null;
        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));

        // This case means that is index that is being processed
        if (url.getPath().equalsIgnoreCase("") || url.getPath().equalsIgnoreCase("/") || url.getPath().equalsIgnoreCase("//") || getFileExtension(url) == null) {
            tempFile = new File(this.getBasePath() + url.getPath());
            
            if (!tempFile.exists()) {
                tempFile.mkdirs();
            }
            
            fileName = this.getBasePath() + url.getPath() + "index.html";

        } else {
            // Create parent dir if not exist
            String parentDir = getParentPath(url);
            // Null means that dont exist parent
            if (parentDir == null) {
                fileName = this.getBasePath();
                tempFile = new File(fileName);
            } else {

                fileName = this.getBasePath() + parentDir;
                tempFile = new File(fileName);
            }
            if (!tempFile.exists()) {
                tempFile.mkdirs();
            }

            fileName = this.getBasePath() + url.getPath();
        }

        fileName = fileName.replace("/", "\\");

        //If have not extension is not file

        // Check if image already exist, if not download it
        File textFile = new File(fileName);
        FileWriter fw = new FileWriter(textFile);
        BufferedWriter bw = new BufferedWriter(fw);
        String line;

        while ((line = in.readLine()) != null) {
 
           String tempLine = this.replaceUrlToDir(line);
            bw.write(tempLine);

        }
        bw.close();

        in.close();
        System.out.println(url.getHost() + url.getHost() + url.getPath() + "has been download successfully");


    }