encoding of text by using java code
<p>the my code by using servlet language that read the text line by line and fill string buffer each 5000 words in a string buffer then display the content in jsp page and I put in header display text in utf-8 the problem is when the text in utf-8 encoding the code read it in unkown character and I want my code to read text in utf-8 and the text shown to user in utf-8 encoding
here is my code for reading the text</p>

<pre><code> try{
   File file = new File(p);         
   l = (int) file.length(); 
   String s = null,strr=null;
   String g = null,m=null;
   int i = 0;
   Scanner input = new Scanner(file); 
   s1 = new StringBuffer();
   s2 = new StringBuffer();
   while (input.hasNextLine()) {
     g = input.nextLine();
     String[] d = g.split(" ");
     int h = d.length;
     i = i + h;
     if (i &gt; 5000) {
       break;
     }
     s1.append(g).append(System.getProperty("line.separator"));
   }
   if(i &gt; 5000) {
     s2.append(g).append(System.getProperty("line.separator"));
     while( input.hasNextLine()) {
     s = input.nextLine(); 
     String[] d = s.split(" ");
     int h = d.length;
     i=0;
     i=i+h;
     if (i &gt; 5000) {
       break;
     }
     s2.append(s).append(System.getProperty("line.separator"));}
     if (input.hasNextLine()) {
       s3.append(s).append(System.getProperty("line.separator"));
       while(input.hasNextLine()) {
         strr = input.nextLine(); 
         s3.append(strr).append(System.getProperty("line.separator"));
       }
     }
   }
 input.close(); 
 } catch (Exception e) {
   e.getMessage();
 }
</code></pre>
