You must have MainActivity.java or some Activity that creates an instance of QuoteBank . You want the constructor to accept the context parameter:
Set a private variable in QuoteBank.java :
private Context mContext;
Designer Setting:
public QuoteBank(Context context) { this.mContext = context; }
Then create an instance in your activity,
QuoteBank quoteBank = new QuoteBank(context);
A context variable can be called inside an action with this or Activity.this , where you replace "Activity" with your activity name. Alternatively, if you are inside a fragment, you can get the context from the View object inside your onCreateView(...) method. Usually by calling view.getContext() .
Now in your method, where you capture assets, you can use the context:
InputStream is = mContext.getAssets().open("QuotesMonkeyBusiness.txt")
Since you are using Android studio, you can either create the main(String[] args) { ... } method, or run it, or simply run the emulator and use Log.d(...) to output the output from the file.
Alternatively, you can also use the following method:
AssetManager am = mContext.getAssets(); InputStream is = am.open("QuotesMonkeyBusiness.txt");
It may also make sense to have QuoteBank as a single-screen instance that can increase efficiency, although it all depends on your requirements, maybe something like:
List<String> allTextLines = QuoteBank.readFromFile(context, path_to_file);
And then in your QuoteBank.java class, you might have a method like this:
public class QuoteBank { private Context mContext; public QuoteBank(Context context) { this.mContext = context; } public List<String> readLine(String path) { List<String> mLines = new ArrayList<>(); AssetManager am = mContext.getAssets(); try { InputStream is = am.open(path); BufferedReader reader = new BufferedReader(new InputStreamReader(is)); String line; while ((line = reader.readLine()) != null) mLines.add(line); } catch (IOException e) { e.printStackTrace(); } return mLines; }
}
and then in my MainActivity.java class, I have the following:
public class MainActivity extends AppCompatActivity { public static final String TAG = MainActivity.class.getSimpleName(); public static final String mPath = "adventur.txt"; private QuoteBank mQuoteBank; private List<String> mLines; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mQuoteBank = new QuoteBank(this); mLines = mQuoteBank.readLine(mPath); for (String string : mLines) Log.d(TAG, string); } @Override public boolean onCreateOptionsMenu(Menu menu) {
This is my project structure:

This is the adventur.txt file downloaded from a random database:

This is my log output:

UPDATE: Why you should not use the scanner in Android
From the official documentation:
http://developer.android.com/reference/java/util/Scanner.html
This class is not as useful as it might seem. It is very inefficient for communication between machines; You should use JSON, protobufs or even XML for this. A very simple use might go away with split (String). To input information from people, using regular expressions specific to the locale makes it not only costly, but also somewhat unpredictable. The Scanner class is not thread safe.
FINAL NOTE:
I highly recommend that you read the documentation of all the objects used here so you can understand the process.