Android:Runtime exception in thread
<p>i am building an android application which involves reading text from a file and some actions on them.I am doing it using a thread(i pass the input stream object (in) to the thread(AsyncTask)).
I have successfully extracted patterns from the file but error occurs(in the debug mode) in the following line where i convert ArrayList to String array.. </p>

<pre><code>String[] str=a.toArray(new String[a.size()]);
</code></pre>

<p>my code is(inside doInBackground):</p>

<pre><code>BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
while ((strLine = br.readLine()) != null) {
    Matcher m = MY_PATTERN.matcher(strLine);
    a = new ArrayList&lt;String&gt;();
    while (m.find()) {
        a.add(m.group(1));
        // s now contains "BAR"
    }
    String[] str=a.toArray(new String[a.size()]);//ERROR STEP
              double ltdo=(Math.round(Double.parseDouble(lt)*100.0)/100.0);
              double lodo=(Math.round(Double.parseDouble(lo)*100.0)/100.0);
}
</code></pre>

<p>My catlog error is:</p>

<pre><code>08-15 16:38:12.980: I/global(384): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
08-15 16:38:52.972: W/dalvikvm(384): threadid=8: thread exiting with uncaught exception (group=0x4001d800)
08-15 16:38:53.360: E/AndroidRuntime(384): FATAL EXCEPTION: AsyncTask #1
08-15 16:38:53.360: E/AndroidRuntime(384): java.lang.RuntimeException: An error occured while executing doInBackground()
08-15 16:38:53.360: E/AndroidRuntime(384):  at android.os.AsyncTask$3.done(AsyncTask.java:200)
08-15 16:38:53.360: E/AndroidRuntime(384):  at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
08-15 16:38:53.360: E/AndroidRuntime(384):  at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
08-15 16:38:53.360: E/AndroidRuntime(384):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
08-15 16:38:53.360: E/AndroidRuntime(384):  at java.util.concurrent.FutureTask.run(FutureTask.java:137)
08-15 16:38:53.360: E/AndroidRuntime(384):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
08-15 16:38:53.360: E/AndroidRuntime(384):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
08-15 16:38:53.360: E/AndroidRuntime(384):  at java.lang.Thread.run(Thread.java:1096)
08-15 16:38:53.360: E/AndroidRuntime(384): Caused by: java.lang.NullPointerException
08-15 16:38:53.360: E/AndroidRuntime(384):  at org.apache.harmony.luni.util.FloatingPointParser.parseDouble(FloatingPointParser.java:263)
08-15 16:38:53.360: E/AndroidRuntime(384):  at java.lang.Double.parseDouble(Double.java:287)
08-15 16:38:53.360: E/AndroidRuntime(384):  at my.GPS.FindLocation.doInBackground(FindLocation.java:67)
08-15 16:38:53.360: E/AndroidRuntime(384):  at my.GPS.FindLocation.doInBackground(FindLocation.java:1)
08-15 16:38:53.360: E/AndroidRuntime(384):  at android.os.AsyncTask$2.call(AsyncTask.java:185)
08-15 16:38:53.360: E/AndroidRuntime(384):  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
08-15 16:38:53.360: E/AndroidRuntime(384):  ... 4 more
</code></pre>
