title: How to import class from another file in java in Android Studio?
body: <p>I'm trying to call the function <em>getUrlContents(string)</em> inside my <em>seismic_text.java</em> file to my <em>MainActivity.java</em> file. How can I call the function from anywhere in the file? Any information or tip is appreciated. I include my files down below. </p>
  
  <p>This is my <em>MainActivity.java</em>:</p>
  
  <pre><code>package bt.alfaquake;
  
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.app.NotificationManager;
  import android.content.Intent;
  import android.view.View;
  import android.app.PendingIntent;
  import android.support.v7.app.ActionBarActivity;
  import android.support.v4.app.NotificationCompat;
  import bt.alfaquake.seismic_text;
  
  public class MainActivity extends AppCompatActivity {   
  
      NotificationCompat.Builder notification;
      private static final int uniqueID = 123;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          notification = new NotificationCompat.Builder(this);
      }    
  }
  </code></pre>
  
  <p>This is my <em>seismic_text.java</em>:
          package bt.alfaquake;</p>
  
  <pre><code>import java.net.*;
  import java.io.*;
  
  public class seismic_text {
  
          public static String getUrlContents(String theUrl) {
              StringBuilder content = new StringBuilder();
              try
              {
                  URL url = new URL(theUrl);
                  URLConnection urlConnection = url.openConnection();
  
                  BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
                  String line;
  
                  while ((line = bufferedReader.readLine()) != null)
                  {
                      content.append(line + "\n");
                  }
                  bufferedReader.close();
              }
              catch(Exception e)
              {
                  e.printStackTrace();
              }
              return content.toString();
          }
      }
  }
  </code></pre>