Ola, estou tentando ler um arquivo html com o código a seguir, mas não está dando certo.
O arquivo “buscape.html” está na mesma pasta do arquivo java.
[code]/*
- Lendo e escrevendo em arquivo
- uso dos comandos indexOf e split
*/
package lerarquivo;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class LerArquivo {
public static void main(String[] args) throws FileNotFoundException, IOException {
InputStream is = new FileInputStream("buscape.html");
is.read();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String linha = br.readLine();
while (linha != null) {
System.out.println(linha);
linha = br.readLine();
}
br.close();
}
// Scanner s = new Scanner(new FileInputStream("…/…/…/buscape.html"));
// while (s.hasNextLine()) {
// System.out.println(s.nextLine());
// }
// s.close();
}
[/code]