Converter arquivo .txt em .html5 e conter ordenado com menu alfabético e ancora

Alguém pode me ajudar?
A conversão deve ser feita via programação.
Não consegui fazer :sweat:

deve ser feito a conversão, passando de um arquivo cidades.txt e criando um novo!

Foi resolvido, segue código:

<html>

{
        int i=0;
    
    RandomAccessFile arquivo = new RandomAccessFile("cidades.txt" , "r");
    RandomAccessFile html = new RandomAccessFile("novo.html","rw"); 
    
    String cidade;
    String alfabeto = "abcdefghijklmnopqrstuvzxwy".toUpperCase();
    
    try
    {
        html.writeBytes("<!DOCTYPE html> \r\n"
            + "<html lang=\"pt-br\"> \r\n"
            + "<head> \r\n"
            + "<title>Cidades do Estado de São Paulo</title> \r\n"
            + "</head> \r\n"
            + "<body> \r\n"
            + " <!- - menu alfabético  --> \r\n");
            
            while(arquivo.getFilePointer() < arquivo.length())
            {
                cidade = arquivo.readLine();
                
                if(cidade.charAt(0) == alfabeto.charAt(i))
                {
                    html.writeBytes("<a href = \"#" + alfabeto.charAt(i) + "\">" + alfabeto.charAt(i) + "</a> \r\n");
                    html.writeBytes("<p id = \"" + alfabeto.charAt(i) + "\" > " + cidade + "</p> \r\n" );

                    if(i<alfabeto.length()-1)
                        i++;
                    
                }
                
                else if(cidade.charAt(0) > alfabeto.charAt(i))
                {
                    if(i<alfabeto.length()-1)
                        i++;
                }
                
                else
                {
                    html.writeBytes("<p> " + cidade + " </p> \r\n");
                }
            }
        html.writeBytes("</body> \r\n"
                + "</html>");
        
        html.close();
        arquivo.close();
    }
    catch(Exception a)
    {
        System.out.println("Erro: "+a.toString());
    }
}

</html>