0

I'm reading a HTML source from URL using simple Input/Output Stream

URL website = new URL(url);
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = context.openFileOutput("pagina.html", 0);
fos.getChannel().transferFrom(rbc, 0, 2000000);
fos.close();

When trying to read what i've downloaded

BufferedReader br = new BufferedReader(new InputStreamReader(context.openFileInput("pagina.html")));
String line;
String content="";
while((line=br.readLine())!=null)
   content += linea;

It stops when a "&&" is found. Original content (using Chrome's code viewer) is:

function addFav() {if (navigator.platform.substring(0,3) == 'Win' && navigator.appName.substring(0,3)=='Mic') {
    document.write('<a href="javascript:void(0)" title="Añadir esta página a Favoritos" onClick="window.external.AddFavorite(location.href,document.title);" class="aTxtPortail">Añadir a Favoritos<\/a>');
} else if (window.sidebar&&window.sidebar.addPanel){
    document.write('<a href="javascript:void(0)" title="Añadir esta página a Favoritos" onClick="window.sidebar.addPanel(document.title,location.href,\'\');" class="aTxtPortail">Añadir a Favoritos<\/a>')
}
}

But readed code ends on:

function addFav(){if (navigator.platform.substring(0,3) == 'Win' ?????????????????????????????????????????????????????????????????????????????

Is there any consideration with the ampersand character when reading byte buffers? Thanks.

m.s.
  • 16,063
  • 7
  • 53
  • 88
Lerkendal
  • 11
  • 2
  • What is the class of context? – laune Oct 15 '15 at 11:04
  • possibly duplicate http://stackoverflow.com/questions/9281629/read-special-characters-in-java-with-bufferedreader – Lovababu Padala Oct 15 '15 at 11:10
  • Thanks for your comments, but it seems to be a different problem, since Charset specification on reader does not change much the output. InputStreamReader isr = new InputStreamReader(is,"ISO-8859-1");InputStreamReader isr = new InputStreamReader(is,"ISO-8859-1"); By the the way, the conflicting source is http://es.kingofsat.net/pos-19.2E.php – Lerkendal Oct 15 '15 at 15:47
  • Thanks, solved using Jsoup.connect() method of Jsoup library. – Lerkendal Oct 16 '15 at 09:37

0 Answers0