Skip to content

Commit 8982cfe

Browse files
committed
Update readme
[skip-ci]
1 parent 218c509 commit 8982cfe

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

README.md

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ to blindly paste code snippets from
3131

3232
It's main features include:
3333

34-
* **Creation** from a wide variety of sources: multiple arrays, integers, streams, random, strings, files, ...
35-
* **Transformation** with many built-in: append, xor, and, hash, shifts, shuffle, reverse, sort, ...
34+
* **Creation** from a wide variety of sources: multiple arrays, integers, [streams](https://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html), random, strings, files, ...
35+
* **Transformation** with many built-in: append, [xor](https://en.wikipedia.org/wiki/Exclusive_or), [and](https://en.wikipedia.org/wiki/Logical_conjunction), [hash](https://en.wikipedia.org/wiki/Cryptographic_hash_function), [shifts](https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts), shuffle, reverse, [checksum](https://en.wikipedia.org/wiki/Checksum), ...
3636
* **Validators** with the ability to arbitrarily combine multiple ones with logical expressions
37-
* **Parsing and Encoding** in most common binary-to-text-encodings: [hex](https://en.wikipedia.org/wiki/Hexadecimal), [base64](https://en.wikipedia.org/wiki/Base64), ...
37+
* **Parsing and Encoding** in most common binary-to-text-encodings: [hex](https://en.wikipedia.org/wiki/Hexadecimal), [base36](https://en.wikipedia.org/wiki/Base36), [base64](https://en.wikipedia.org/wiki/Base64), ...
3838
* **Immutable, Mutable and Read-Only** versions
39-
* **Utility Features** like `indexOf`, `count`, `isEmpty`, `bitAt`, ...
39+
* **Utility Features** like `indexOf`, `count`, `isEmpty`, `bitAt`, `contains` ...
4040
* **Flexibility** provide your own Transformers, Validators and Encoders
4141

4242
It is written in [Java 7](https://en.wikipedia.org/wiki/Java_version_history#Java_SE_7) to keep backwards compatibility with *Android* and older *Java* applications.
@@ -136,10 +136,10 @@ Bytes.from(asciiString, StandardCharset.US_ASCII) //any charset
136136
And other types:
137137

138138
```java
139-
Bytes.from(byteInputStream); //any inputStream
139+
Bytes.from(byteInputStream); //any java.io.InputStream
140140
Bytes.from(byteList); //List<Byte> byteList = ...
141-
Bytes.from(myBitSet); //BitSet myBitSet = ...
142-
Bytes.from(bigInteger);
141+
Bytes.from(myBitSet); //java.util.BitSet myBitSet = ...
142+
Bytes.from(bigInteger); //java.math.BigInteger
143143
Bytes.from(file); //reads bytes from any java.io.File
144144
Bytes.from(dataInput, 16); //reads bytes from any java.io.DataInput
145145
```
@@ -173,10 +173,10 @@ Bytes result = Bytes.wrap(array1).append((byte) 3);
173173
**Bitwise operations**: XOR, OR, AND, NOT as well as left and right shifts and switching bits:
174174

175175
```java
176-
Bytes.wrap(array).xor(array2);
177-
Bytes.wrap(array).or(array2);
178-
Bytes.wrap(array).and(array2);
179-
Bytes.wrap(array).negate();
176+
Bytes.wrap(array).xor(array2); // 0010 0011 xor() 1011 1000 = 1001 1011
177+
Bytes.wrap(array).or(array2); // 0010 0011 or() 1101 0100 = 1111 0111
178+
Bytes.wrap(array).and(array2); // 0010 0011 and() 1011 1000 = 0010 0000
179+
Bytes.wrap(array).negate(); // 0010 0011 negate() = 1101 1100
180180
Bytes.wrap(array).leftShift(8);
181181
Bytes.wrap(array).rightShift(8);
182182
Bytes.wrap(array).switchBit(3, true);
@@ -198,7 +198,7 @@ Bytes resized = Bytes.wrap(array).resize(3); //from {3, 9, 2, 1} to {9, 2, 1}
198198
**Hashing** the internal byte array using the [`MessageDigest`](https://docs.oracle.com/javase/7/docs/api/java/security/MessageDigest.html) Java crypto API:
199199

200200
```java
201-
Bytes hash = Bytes.wrap(array).sha256();
201+
Bytes hash = Bytes.wrap(array).hashSha256();
202202
Bytes hash = Bytes.wrap(array).hash("MD5");
203203
```
204204

@@ -247,8 +247,9 @@ Bytes.wrap(array).transform(shuffle());
247247

248248
### Parser and Encoder for Binary-Text-Encodings
249249

250-
This library can parse and encode a variety of encodings: binary, decimal, octal,
251-
hex, base36 and base64. Additionally custom parsers are supported by providing your own
250+
This library can parse and encode a variety of encodings: binary, decimal, [octal](https://en.wikipedia.org/wiki/Octal),
251+
[hex](https://en.wikipedia.org/wiki/Hexadecimal), [base36](https://en.wikipedia.org/wiki/Base36) and
252+
[base64](https://en.wikipedia.org/wiki/Base64). Additionally custom parsers are supported by providing your own
252253
implementation:
253254

254255
```java
@@ -350,7 +351,7 @@ Validators also support nestable logical expressions AND, OR as well as NOT:
350351

351352
```java
352353
Bytes.allocate(0).validate(or(exactLength(1), exactLength(0))) //true
353-
Bytes.allocate(21).validate(and(atLeast(3), atMost(20))) //true
354+
Bytes.allocate(19).validate(and(atLeast(3), atMost(20))) //true
354355
Bytes.allocate(2).validate(not(onlyOf((byte) 0))); //false
355356
```
356357

@@ -402,15 +403,15 @@ To primitives (if the internal array is not too long)
402403
```java
403404
Bytes.wrap(array).toByte();
404405
Bytes.wrap(array).toInt();
405-
Bytes.wrap(array).toLong();
406+
Bytes.wrap(array).toDouble();
406407
```
407408

408409
To other collections
409410

410411
```java
411412
Bytes.wrap(array).toList(); // of type List<Byte>
412413
Bytes.wrap(array).toObjectArray(); // of type Byte[]
413-
Bytes.wrap(array).toBitSet();
414+
Bytes.wrap(array).toBitSet(); //of type java.util.BitSet
414415
```
415416

416417
and to [`BigInteger`](https://docs.oracle.com/javase/7/docs/api/java/math/BigInteger.html) of course:

0 commit comments

Comments
 (0)