To create a java desktop application that accesses the internet and le an xml file. Well, that's the initial propolis. I am using the Socket class to do communication between the server and the application. But now I do not know how to read XML. I changed my code, while I want to write the XML. Still looking like.
public static void main(String[] args) throws IOException
{
try
{
//conectando
URL url = new URL("http://www.cinemark.com.br/mobile/xml/films/");
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
//pegando informações
BufferedReader leitor = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
String line;
FileWriter arquivo = new FileWriter("D:\Documentos\GitHub\arquivo.txt");
PrintWriter gravArq = new PrintWriter(arquivo);
while ((line = leitor.readLine()) != null)
{
gravArq = gravArq.printf(line);
}
leitor.close();
urlConnection.disconnect();
}
catch (MalformedURLException ex) { System.out.println("Erro ao criar url: formato invalido"); }
}