<commit_before>JavaNetworking
==============

[![Build Status](https://travis-ci.org/JavaNetworking/JavaNetworking.svg?branch=master)](https://travis-ci.org/JavaNetworking/JavaNetworking)

JavaNetworking is an asynchronous java networking library.


## Basic usage

### Build

##### Windows
```cmd
gradlew.bat build
```

##### Unix
```bash
./gradlew build
```

##### Built JAR path
```
JavaNetworking/library/build/libs/JavaNetworking-*.*.*.jar
```

### Run tests

##### Windows
```cmd
gradlew.bat test
```

##### Unix
```bash
./gradlew test
```

### Download JSON string

```java
String urlString = "https://api.github.com/search/repositories?q=tetris+language:assembly&sort=stars&order=desc";

URLRequest request = URLRequest.requestWithURLString(urlString);

JSONURLRequestOperation operation = JSONURLRequestOperation.operationWithURLRequest(request, new HTTPCompletion() {
    @Override
    public void failure(URLRequest request, Throwable t) {
        System.out.println("Throwable: " + t);
    }
    @Override
    public void success(URLRequest request, Object responseData) {
        System.out.println("Response data:\n" + responseData);
    }
});
operation.start();
```

### Download image

```java
String image_url = "http://www.insidefacebook.com/wp-content/uploads/2013/01/profile-150x150.png";

URLRequest request = URLRequest.requestWithURLString(image_url);

ImageURLRequestOperation operation = ImageURLRequestOperation.operationWithURLRequest(request, new HTTPCompletion() {
	@Override
	public void failure(URLRequest request, Throwable t) {
    	System.out.println("Throwable: " + t);
	}
	@Override
	public void success(URLRequest request, Object responseData) {
		System.out.println("Downloaded: " + ((byte[])responseData).length + " bytes");
	}
});
operation.start();
```

## Credits

JavaNetworking is based upon the popular iOS and OSX library [AFNetworking](http://afnetworking.com/).
<commit_msg>Added XML example to README.md<commit_after>JavaNetworking
==============

[![Build Status](https://travis-ci.org/JavaNetworking/JavaNetworking.svg?branch=master)](https://travis-ci.org/JavaNetworking/JavaNetworking)

JavaNetworking is an asynchronous java networking library.


## Basic usage

### Build

##### Windows
```cmd
gradlew.bat build
```

##### Unix
```bash
./gradlew build
```

##### Built JAR path
```
JavaNetworking/library/build/libs/JavaNetworking-*.*.*.jar
```

### Run tests

##### Windows
```cmd
gradlew.bat test
```

##### Unix
```bash
./gradlew test
```

### Download JSON
Response is a 'com.javanetworking.gson.JsonElement' object created from the JSON response.

```java
String urlString = "https://api.github.com/search/repositories?q=tetris+language:assembly&sort=stars&order=desc";

URLRequest request = URLRequest.requestWithURLString(urlString);

JSONURLRequestOperation operation = JSONURLRequestOperation.operationWithURLRequest(request, new HTTPCompletion() {
    @Override
    public void failure(URLRequest request, Throwable t) {
        System.out.println("Throwable: " + t);
    }
    @Override
    public void success(URLRequest request, Object responseData) {
        System.out.println("Response data:\n" + responseData);
    }
});
operation.start();
```

### Download XML
Response is a 'org.w3c.dom.Document' object created from the XML response.

```java
String urlString = "http://httpbin.org/get";
        
URLRequest request = URLRequest.requestWithURLString(urlString);

XMLURLRequestOperation.operationWithURLRequest(request, new HTTPCompletion() {
    @Override
    public void failure(URLRequest request, Throwable t) {
        System.out.println("Throwable: " + t);
    }
    @Override
    public void success(URLRequest request, Object response) {
        System.out.println("Response data:\n" + response);
    }
}).start();
```

### Download image

```java
String image_url = "http://www.insidefacebook.com/wp-content/uploads/2013/01/profile-150x150.png";

URLRequest request = URLRequest.requestWithURLString(image_url);

ImageURLRequestOperation operation = ImageURLRequestOperation.operationWithURLRequest(request, new HTTPCompletion() {
	@Override
	public void failure(URLRequest request, Throwable t) {
    	System.out.println("Throwable: " + t);
	}
	@Override
	public void success(URLRequest request, Object responseData) {
		System.out.println("Downloaded: " + ((byte[])responseData).length + " bytes");
	}
});
operation.start();
```

## Credits

JavaNetworking is based upon the popular iOS and OSX library [AFNetworking](http://afnetworking.com/).

{'fraction_non_alphanumeric': 0.14944812362030904, 'fraction_numerical': 0.005518763796909493, 'mean_word_length': 5.049399198931909, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '431252', 'n_tokens_mistral': 1415, 'n_tokens_neox': 1320, 'n_words': 287}