0

I want to load text from URL, store to string and append the loaded text to String image_url = "http://example.com/example" + yourData; as shown below. I cannot get the data from txt file and append in another URL. Help needed. Thanks!

try {
    // Create a URL for the desired page
    URL url = new URL("example.com/thefile.txt");

    // Read all the text returned by the server
    BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
    StringBuilder builder = new StringBuilder();
    String str;
    while ((str = in.readLine()) != null) {
        // str is one line of text; readLine() strips the newline character(s)
        builder.append(str);
    }

    in.close();
    String yourData = builder.toString();
} catch (MalformedURLException e) {
} catch (IOException e) {
}

// Loader image - will be shown before loading image
int loader = R.drawable.loader;
ImageView image = (ImageView) findViewById(R.id.image);
String image_url = "http://example.com/example" + yourData;
ImageLoader imgLoader = new ImageLoader(getApplicationContext());
imgLoader.DisplayImage(image_url, loader, image);
Leszek Jasek
  • 2,206
  • 1
  • 23
  • 30

1 Answers1

0

Use Properties class

For more details

https://www.seleniumeasy.com/selenium-tutorials/read-data-from-properties-file-using-java-selenium

Yogesh Rathi
  • 6,331
  • 4
  • 51
  • 81