UTF8 Error

I'm fetching and reading a page that it supposed to be utf8 encoded but when a page has an invalid utf8 character, BufferReader.readLine() gives IOException. How can that line be salvaged and by replacing bad character with '?' or totally droping bad char? bellow is sample function that reads a file that is utf8 mostly but sometimes has some messedup charachter (within a second) and returns its contents

StringBuffer readPage (String urlString) //"http://www.domain.com/badfile.txt"
StriĆ­g encoding = "UTF8";
long stopTime = System.currentTimeMillis() + 1000L; StringBuffer buffer = null; String inputLine = null; BufferedReader bufferedReader = null; URL url = null; HttpURLConnection urlc = null; try {  url = new URL((urlString); } catch (java.net.MalformedURLException murle){} try {  urlc = (HttpURLConnection) url.openConnection(); } catch (IOException ex3){} urlc.setAllowUserInteraction(false);
urlc.setDoInput(true);
urlc.setDoOutput(false);
urlc.setUseCaches(false);
try
{
 urlc.setRequestMethod("GET");
} catch (ProtocolException ex4){}
try
{
 urlc.connect();
} catch (IOException ex5){}
try
{
bufferedReader = new BufferedReader(new InputStreamReader(urlc.getInputStream(), encoding)); } catch (java.io.UnsupportedEncodingException uee){} while ((stopTime - System.currentTimeMillis()) > 0) {  try  {
  inputLine = bufferedReader.readLine();
 }
 catch (IOException ex)
 {
  if (ex.getMessage() != null && ex.getMessage().indexOf("Read timed out")
> -1)
  {
   return null;
  }
  else (sun.io.MalformedInputException mie)
  {
   // here utf8 error is cought
  }
 }
 if (inputLine == null)
 {
  break;
 }
 buffer.append(inputLine);

}
return buffer;
}
-------------------------------------------------
 sun.io.MalformedInputException
         at sun.io.ByteToCharUTF8.convert(ByteToCharUTF8.java(Compiled Code))
         at sun.nio.cs.StreamDecoder$ConverterSD.convertInto(StreamDecoder.java(Inlined
Compiled Code))
         at sun.nio.cs.StreamDecoder$ConverterSD.implRead(StreamDecoder.java(Compiled
Code))
         at sun.nio.cs.StreamDecoder.read(StreamDecoder.java(Compiled Code))
         at java.io.InputStreamReader.read(InputStreamReader.java(Compiled
Code))
         at java.io.BufferedReader.fill(BufferedReader.java(Inlined
Compiled Code))
         at java.io.BufferedReader.readLine(BufferedReader.java(Compiled
Code))
         at java.io.BufferedReader.readLine(BufferedReader.java(Inlined
Compiled Code))

Thanks for your help.
petkaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kelvin_KingCommented:
just continue after catching the exception.

else (sun.io.MalformedInputException mie)
  {
   continue;
  }

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CEHJCommented:
Might not the exceptions indicate that it's *not* UTF-8? If so, try reading it with another encoding
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.