First get the file size using File.length method. or HttpConnection.getContentLength() if its Internet based resource.
in the while loop the percentage is
while(in.ready()){
string = string +in.readLine();
percentage = (string.length() / fileLength) * 100;
}
By the way its not a good practice to use
string + in.readLine()
Use a StringBuffer to this concatenation.