There is a file on the server http://site.com/test.txt .

How to get the text out of it and compare it?

1 answer 1

You can get the text, for example, using OkHttp :

 public class MainActivity extends AppCompatActivity { private OkHttpClient mHttpClient; private String mText; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mHttpClient = new OkHttpClient(); try { run(); } catch (Exception e) { e.printStackTrace(); } } public void run() throws Exception { Request request = new Request.Builder() .url("http://site.com/test.txt") .build(); mHttpClient.newCall(request).enqueue(new Callback() { @Override public void onFailure(Request request, IOException e) { e.printStackTrace(); } @Override public void onResponse(final Response response) throws IOException { if (!response.isSuccessful()) throw new IOException("Unexpected code " + response); mText = response.body().string(); } }); } } 

You can compare the resulting text using the equals(...) method of the String class.