Sending text file line by line to server
<p>This code is supposed to send data from a text file line by line to a server. But its sending only the 1st line. how to move to next line of text file in android. And after sending I want to delete the line.</p>

<pre><code>File file = new File(Environment.getExternalStorageDirectory(),"/BPCLTracker1/gpsdata.txt");
File f1=new File(Environment.getExternalStorageDirectory(),"/BPCLTracker1/gpsdata.txt");
RandomAccessFile in = null;
RandomAccessFile in1 = null;
try
{
  in = new RandomAccessFile(file, "rw");
  in1= new RandomAccessFile(f1, "rw");}
  catch (FileNotFoundException e) 
  {// TODO Auto-generated catch bloc e.printStackTrace();}
  String line ="0";
  while (true)
  {
     try 
     {
        if (isInternetOn())
        {
           while ((line = in.readLine()) != null)
           {
                 HttpEntity entity;
                 HttpClient client = new DefaultHttpClient();
                 String url = "some url is here";
                 HttpPost request = new HttpPost(url);
                 StringEntity se = new StringEntity(line);
                 se.setContentEncoding("UTF-8");
                 se.setContentEncoding(new BasicHeader(
                 HTTP.CONTENT_TYPE, "application/json"));
                 entity = se;
                 request.setEntity(entity);
                 HttpResponse response = client.execute(request);
                 entity = response.getEntity();
                 if (entity != null) {}
           }
       }
   }
}
</code></pre>

<p>Thank You</p>
