Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.google.gson.Gson;
- import java.net.URL;
- import java.net.URLConnection;
- import java.util.Scanner;
- public class RadioContent
- {
- private String url;
- private String stringContent;
- private RadioContent gsonContent;
- private String find;
- public Object getValue( String find )
- {
- return gsonContent.find;
- }
- public void setURL( String url )
- {
- this.url = url;
- }
- public void loadContent()
- {
- URLConnection connection = null;
- try
- {
- connection = new URL( url ).openConnection();
- Scanner scanner = new Scanner( connection.getInputStream() );
- scanner.useDelimiter( "\\Z" );
- stringContent = scanner.next();
- }
- catch( Exception ex )
- {
- ex.printStackTrace();
- }
- }
- public void convertToJson()
- {
- Gson gson = new Gson();
- gsonContent = gson.fromJson( stringContent, RadioContent.class );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement