title: How to copy contents of test file which is on server into an array
body: <p>I am almost done with my music player. I am able to read my file which contains song_name and its url which is on the Server but dont know how to store these info into array song_name[] and song_url[] respectively. This is my complete code and the link is inside the code.</p>
  
  <pre><code>package com.hiphop.streamingmediaplayer;i
  import java.io.IOException;  
  import java.net.URL;
  import java.util.Scanner;
  
  import android.app.Activity;
  import android.media.AudioManager;
  import android.media.MediaPlayer;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.View;
  import android.widget.Button;
  
  public class Jsonmedia extends Activity {
      private MediaPlayer mp;
      Button play;
      String song_url[], song_name[];
  
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.jsonview);
  
      try {
          URL url = new URL("http://reallifethug.webs.com/temp_list.txt");
          Scanner s = new Scanner(url.openStream());
          while (s.hasNextLine()) {
              song_url = s.nextLine();
          }
          s.close();
      } catch (IOException ex) {
          // there was some connection problem, or the file did not exist on
          // the server,
          // or your URL was not in the right format.
          // think about what to do now, and put it here.
          ex.printStackTrace(); // for now, simply output it.
      }
  
      mp = new MediaPlayer();
      mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
  
      play = (Button) findViewById(R.id.play);
  
      play.setOnClickListener(new View.OnClickListener() {
  
          public void onClick(View v) {
              // TODO Auto-generated method stub
  
              try {
                  mp.setDataSource(song_url);
              } catch (IllegalArgumentException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              } catch (SecurityException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              } catch (IllegalStateException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              } catch (IOException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
              try {
                  mp.prepare();
              } catch (IllegalStateException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              } catch (IOException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
              }
              mp.start();
          }
      });
  
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.jsonmedia, menu);
      return true;
  
  }
  </code></pre>
  
  <p>}</p>