|
21 | 21 | import java.net.URI;
|
22 | 22 | import java.net.URL;
|
23 | 23 | import java.nio.charset.Charset;
|
| 24 | +import java.nio.file.Path; |
24 | 25 | import java.text.DateFormat;
|
25 | 26 | import java.time.Duration;
|
26 | 27 | import java.time.Instant;
|
|
38 | 39 | import java.util.OptionalInt;
|
39 | 40 | import java.util.OptionalLong;
|
40 | 41 | import java.util.concurrent.CompletableFuture;
|
41 |
| - |
42 | 42 | import java.util.regex.Matcher;
|
| 43 | + |
43 | 44 | import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
|
44 | 45 | import org.assertj.core.api.filter.FilterOperator;
|
45 | 46 | import org.assertj.core.api.filter.Filters;
|
|
60 | 61 | import org.assertj.core.util.CanIgnoreReturnValue;
|
61 | 62 | import org.assertj.core.util.CheckReturnValue;
|
62 | 63 | import org.assertj.core.util.Files;
|
| 64 | +import org.assertj.core.util.Paths; |
63 | 65 | import org.assertj.core.util.URLs;
|
64 | 66 | import org.assertj.core.util.introspection.FieldSupport;
|
65 | 67 |
|
@@ -1652,6 +1654,54 @@ public static List<String> linesOf(File file, String charsetName) {
|
1652 | 1654 | return Files.linesOf(file, charsetName);
|
1653 | 1655 | }
|
1654 | 1656 |
|
| 1657 | + /** |
| 1658 | + * Loads the text content of a path into a list of strings with the default charset, each string corresponding to a |
| 1659 | + * line. |
| 1660 | + * The line endings are either \n, \r or \r\n. |
| 1661 | + * |
| 1662 | + * @param path the path. |
| 1663 | + * @return the content of the file. |
| 1664 | + * @throws NullPointerException if the given charset is {@code null}. |
| 1665 | + * @throws UncheckedIOException if an I/O exception occurs. |
| 1666 | + * |
| 1667 | + * @since 3.23.0 |
| 1668 | + */ |
| 1669 | + public static List<String> linesOf(Path path) { |
| 1670 | + return Paths.linesOf(path, Charset.defaultCharset()); |
| 1671 | + } |
| 1672 | + |
| 1673 | + /** |
| 1674 | + * Loads the text content of a path into a list of strings, each string corresponding to a line. |
| 1675 | + * The line endings are either \n, \r or \r\n. |
| 1676 | + * |
| 1677 | + * @param path the path. |
| 1678 | + * @param charset the character set to use. |
| 1679 | + * @return the content of the file. |
| 1680 | + * @throws NullPointerException if the given charset is {@code null}. |
| 1681 | + * @throws UncheckedIOException if an I/O exception occurs. |
| 1682 | + * |
| 1683 | + * @since 3.23.0 |
| 1684 | + */ |
| 1685 | + public static List<String> linesOf(Path path, Charset charset) { |
| 1686 | + return Paths.linesOf(path, charset); |
| 1687 | + } |
| 1688 | + |
| 1689 | + /** |
| 1690 | + * Loads the text content of a path into a list of strings, each string corresponding to a line. The line endings are |
| 1691 | + * either \n, \r or \r\n. |
| 1692 | + * |
| 1693 | + * @param path the path. |
| 1694 | + * @param charsetName the name of the character set to use. |
| 1695 | + * @return the content of the file. |
| 1696 | + * @throws NullPointerException if the given charset is {@code null}. |
| 1697 | + * @throws UncheckedIOException if an I/O exception occurs. |
| 1698 | + * |
| 1699 | + * @since 3.23.0 |
| 1700 | + */ |
| 1701 | + public static List<String> linesOf(Path path, String charsetName) { |
| 1702 | + return Paths.linesOf(path, charsetName); |
| 1703 | + } |
| 1704 | + |
1655 | 1705 | // --------------------------------------------------------------------------------------------------
|
1656 | 1706 | // URL/Resource methods : not assertions but here to have a single entry point to all AssertJ features.
|
1657 | 1707 | // --------------------------------------------------------------------------------------------------
|
|
0 commit comments