Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. truncaArchivoDespuesDe("<body>");
  2.  
  3.  
  4.  
  5. public void truncaArchivoDespuesDe(String etiqueta) throws IOException {
  6. RandomAccessFile raf = new RandomAccessFile("ArchivoDescargado.html","rw");
  7. String linea = raf.readLine();
  8. while (linea != null) {
  9. if (linea.equals(etiqueta)) {
  10. raf.setLength(raf.getFilePointer()); //aqui truncamos el archivo a su
  11. // nuevo tamaño que será el de la posición
  12. // actual (en el siguiente renglón de la etiqueta encontrada)
  13. return;
  14. }
  15. linea = raf.readLine();
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement