Sobes.tech
Junior — Middle

What methods and tools have you used to gather data from various sources in your project?

sobes.tech AI

Answer from AI

To collect data from various sources in projects, I usually use the following methods and tools:

  • Using APIs: making requests to REST or SOAP services with HTTP clients (for example, HttpClient in Java).
  • Parsing files: reading CSV, JSON, XML using libraries (for example, Jackson for JSON, OpenCSV for CSV).
  • Integration with databases: JDBC for connecting and querying data from relational databases.
  • Using ETL tools (for example, Apache NiFi, Talend) for more complex data flows.
  • Scripts and automation: writing scripts in Java using schedulers (Quartz) for regular collection.

Example of a simple request to a REST API in Java using HttpClient:

HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
    .uri(URI.create("https://api.example.com/data"))
    .build();

HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
String responseBody = response.body();
// then parse responseBody and process data