Extensions to the Java standard library, some tool methods related to File, IO, primitive types, String, Array, and Collection
This library has been published to mavenCentral
. Add the following dependencies to your module build.gradle
file :
implementation "io.github.panpf.tools4j:tools4j:${LAST_VERSION}"
implementation "io.github.panpf.tools4j:tools4j-ktx:${LAST_VERSION}" // Kotlin extension, not required
The "io.github.panpf.tools4j:tools4j:${LAST_VERSION}" dependency will add all the modules included in tools4j to your project (Except for 'tools4j-test'). If you only need of one of the modules, you can just add it to your project, all supported modules as follows:
implementation "io.github.panpf.tools4j:tools4j-annotation:${LAST_VERSION}"
implementation "io.github.panpf.tools4j:tools4j-annotation-ktx:${LAST_VERSION}" // Kotlin extension, not required
implementation "io.github.panpf.tools4j:tools4j-base64:${LAST_VERSION}"
implementation "io.github.panpf.tools4j:tools4j-base64-ktx:${LAST_VERSION}" // Kotlin extension, not required
implementation "io.github.panpf.tools4j:tools4j-compare:${LAST_VERSION}"
implementation "io.github.panpf.tools4j:tools4j-crypto:${LAST_VERSION}"
implementation "io.github.panpf.tools4j:tools4j-crypto-ktx:${LAST_VERSION}" // Kotlin extension, not required
implementation "io.github.panpf.tools4j:tools4j-date:${LAST_VERSION}"
implementation "io.github.panpf.tools4j:tools4j-date-ktx:${LAST_VERSION}" // Kotlin extension, not required
implementation "io.github.panpf.tools4j:tools4j-environment:$LAST_VERSION"
implementation "io.github.panpf.tools4j:tools4j-io:$LAST_VERSION"
implementation "io.github.panpf.tools4j:tools4j-io-ktx:$LAST_VERSION" // Kotlin extension, not required
implementation "io.github.panpf.tools4j:tools4j-lang:${LAST_VERSION}"
implementation "io.github.panpf.tools4j:tools4j-lang-ktx:${LAST_VERSION}" // Kotlin extension, not required
implementation "io.github.panpf.tools4j:tools4j-math:${LAST_VERSION}"
implementation "io.github.panpf.tools4j:tools4j-math-ktx:${LAST_VERSION}" // Kotlin extension, not required
implementation "io.github.panpf.tools4j:tools4j-net:${LAST_VERSION}"
implementation "io.github.panpf.tools4j:tools4j-premise:${LAST_VERSION}"
implementation "io.github.panpf.tools4j:tools4j-premise-ktx:${LAST_VERSION}" // Kotlin extension, not required
implementation "io.github.panpf.tools4j:tools4j-ranges:${LAST_VERSION}"
implementation "io.github.panpf.tools4j:tools4j-ranges-ktx:${LAST_VERSION}" // Kotlin extension, not required
implementation "io.github.panpf.tools4j:tools4j-ranges-date:${LAST_VERSION}"
implementation "io.github.panpf.tools4j:tools4j-ranges-date-ktx:${LAST_VERSION}" // Kotlin extension, not required
implementation "io.github.panpf.tools4j:tools4j-reflect:${LAST_VERSION}"
implementation "io.github.panpf.tools4j:tools4j-reflect-ktx:${LAST_VERSION}" // Kotlin extension, not required
implementation "io.github.panpf.tools4j:tools4j-regex:${LAST_VERSION}"
implementation "io.github.panpf.tools4j:tools4j-regex-ktx:${LAST_VERSION}" // Kotlin extension, not required
implementation "io.github.panpf.tools4j:tools4j-security:${LAST_VERSION}"
implementation "io.github.panpf.tools4j:tools4j-security-ktx:${LAST_VERSION}" // Kotlin extension, not required
implementation "io.github.panpf.tools4j:tools4j-sequences:${LAST_VERSION}"
implementation "io.github.panpf.tools4j:tools4j-test:${LAST_VERSION}" // Not included in 'io.github.panpf.tools4j:tools4j'
implementation "io.github.panpf.tools4j:tools4j-test-ktx:${LAST_VERSION}" // Kotlin extension, not required, Not included in 'io.github.panpf.tools4j:tools4j-ktx'
implementation "io.github.panpf.tools4j:tools4j-zip:${LAST_VERSION}"
implementation "io.github.panpf.tools4j:tools4j-zip-ktx:${LAST_VERSION}" // Kotlin extension, not required
- Annotationx: Annotationx.java (Test) | Annotationx.kt (Test)
- getAnnotationFromEnum
- Base64x: Base64x.java (Test) | Base64x.kt (Test)
- encode, encodeToString, decode, decodeToString
- Comparex: Comparex.java (Test)
- areEqual, compareValues, compareValuesBy, compareBy,
- compareByDescending, naturalOrder, reverseOrder, maxOf, minOf
- Aesx: Aesx.java (Test) | Aesx.kt (Test)
- createKey, createKeyByPassword, keyFromBytes, keyFromBase64, encrypt, encryptToBase64, decrypt,
- decryptFromBase64, decryptToString, decryptToStringFromBase64
- Desx: Desx.java (Test) | Desx.kt (Test)
- createKeyByPassword, encrypt, encryptToBase64, decrypt,
- decryptFromBase64, decryptToString, decryptToStringFromBase64
- Keyx: Keyx.java (Test) | Keyx.kt (Test)
- toBase64, toBytes
- Rsax: Rsax.java (Test) | Rsax.kt (Test)
- createKey, pubKeyFromBase64, priKeyFromBase64, sign, signToBase64, verify, verifyFromBase64,
- encrypt, encryptToBase64, decrypt, decryptFromBase64, decryptToString, decryptToStringFromBase64
- Datex: Datex.java (Test) | Datex.kt (Test)
- createCalendar, toDate, format, formatDuration, getCalendarField,
- addToDate, addCalendarField, isSame[Year, Month...], differField,
- Environmentx: Environmentx.java (Test)
- getWorkspaceDir, isClassInJar, getClassInDir, getClassInJarFile
- Filex: Filex.java (Test) | Filex.kt (Test)
- mkdirsOrThrow, mkdirsOrCheck, createNewFileOrThrow, createNewFileOrCheck, ensureFileNotExist,
- ensureDirNotExist, clean, cleanRecursively, lengthRecursively, listRecursively, listFilesRecursively,
- listCount, listCountRecursively, getAllExtension, getNameWithoutAllExtension, createFileTree,
- compareFilePath, formatFileSize, formatMediumFileSize, formatShortFileSize, formatCompactFileSize,
- formatMediumCompactFileSize, formatShortCompactFileSize, requireExist, requireIsDir, requireIsFile,
- copyTo, copyRecursively, deleteRecursively, startsWith, endsWith, normalize, resolve, resolveSibling,
- createTempDir, createTempFile, getExtension, getNameWithoutExtension, toRelativeString, relativeTo,
- relativeToOrSelf, relativeToOrNull, isRooted, toComponents, getInvariantSeparatorsPath, subPath,
- inputStream, bufferedInputStream, reader, bufferedReader, readBytes, readText, readLines, useLines,
- forEachBlock, forEachLine, outputStream, bufferedOutputStream, writer, bufferedWriter, printWriter,
- writeBytes, appendBytes, writeText, appendText, walk, walkTopDown, walkBottomUp,
- testFilterFileNameIllegalCharacters, testFilterFileNameIllegalCharactersOrNull
- IOx: IOx.java (Test) | IOx.kt (Test)
- closeQuietly, readBytesAndClose, readTextAndClose, writeByteAndClose, writeBytesAndClose,
- writeTextAndClose, writeCharAndClose, writeCharsAndClose, copyTo, inputStream, byteInputStream,
- reader, writer, buffered, bufferedReader, bufferedWriter, readLines, readBytes, readText,
- lineIterable, useLines, forEachLine
- Booleanx: Booleanx.java (Test) | Booleanx.kt (Test)
- isTrue, isFalse, isNullOrTrue, isNullOrFalse
- Charx: Charx.java (Test) | Charx.kt (Test)
- isBlank, isNotBlank, notBlankOr, isChinese, isNotChinese, chineseOr, isNotDigit, digitOr, isNotLetter,
- letterOr, isNotLetterOrDigit, letterOrDigitOr, isDigit, isLetter, isLetterOrDigit, equals
- Numberx: Numberx.java (Test) | Numberx.kt (Test)
- requireNotZero, pad, orZero, to*OrDefault, to*OrZero, toHexString, toHexStringOr, toHexStringOrNull,
- toBinaryString, toBinaryStringOr, toBinaryStringOrNull, toOctalString, toOctalStringOr, toOctalStringOrNull
- Objectx: Objectx.java (Test) | Objectx.kt (Test)
- toSimpleString
- Stringx: Stringx.java (Test) | Stringx.kt (Test)
- isSafe, isNotSafe, safeOr, safeOrNull, requireSafe, requireNotSafe, notBlankOr, isNotNullOrBlank,
- notNullOrBlankOr, notEmptyOr, isNotNullOrEmpty, notNullOrEmptyOr, isChinese, isNotChinese, chineseOr,
- isDigit, isNotDigit, digitOr, isLetter, isNotLetter, letterOr, isLetterOrDigit, isNotLetterOrDigit,
- letterOrDigitOr, containsAny, containsAll, orEmpty, orDefault, emptyToNull, blankToNull, filterBlank,
- removeChar, removeFirstChar, removeLastChar, removeIndex, limit, replaceNoRepeat,
- firstLetterUpperCase, firstLetterUpperCase, hiddenStartChars, hiddenMiddleChars, hiddenEndChars,
- isBlank, isNotBlank, isNullOrBlank, isEmpty, isNotEmpty, isNullOrEmpty, indices, lastIndex,
- hasSurrogatePairAt, startsWith, endsWith, equals, removeRange, removePrefix, removeSuffix,
- removeSurrounding, capitalize, decapitalize, padStart, padEnd, matches, regionMatches,
- regionMatchesImpl, find, findLast, findAnyOf, findLastAnyOf, first, firstOrNull, last, lastOrNull,
- getOrElse, getOrNull, indexOf, indexOfAny, indexOfFirst, indexOfLast, lastIndexOf, lastIndexOfAny,
- subSequence, substring, substringBefore, substringAfter, substringBeforeLast, substringAfterLast,
- toByteArray, reversed, filterTo, filter, filterIndexedTo, filterIndexed, filterNotTo, filterNot,
- trim, trimStart, trimEnd, iterator, iterable, replaceRange, replaceBefore, replaceBeforeLast,
- replaceAfter, replaceAfterLast, replace, replaceFirst, commonPrefixWith, commonSuffixWith, contains,
- splitToIterable, split, lineIterable, lines, elementAt, elementAtOrElse, elementAtOrNull, single,
- singleOrNull, drop, dropLast, dropLastWhile, dropWhile, slice, take, takeLast, takeLastWhile, takeWhile,
- associateTo, associate, associateByTo, associateBy, toCollection, toHashSet, toList, toSet, toSortedSet,
- flatMap, flatMapTo, groupBy, groupByTo, mapTo, map, mapIndexedTo, mapIndexed, mapNotNullTo,
- mapNotNull, mapIndexedNotNullTo, mapIndexedNotNull, withIndex, all, any, count, fold,
- foldIndexed, foldRight, foldRightIndexed, forEach, forEachIndexed, maxOrNull, maxWithOrNull,
- maxByOrNull, minOrNull, minWithOrNull, minByOrNull, none, onEach, reduce, reduceIndexed,
- reduceRight, reduceRightIndexed, sumBy, sumByDouble, chunked, chunkedIterable, partition,
- windowed, windowedIterable, zip, zipWithNext, asIterable, ifBlank, ifEmpty
- Throwablex: Throwablex.java (Test) | Throwablex.kt (Test)
- stackTraceToString
- Mathx: Mathx.java (Test) | Mathx.kt (Test)
- divide, divideToInt, divideToLong, scale, proportion, percent, format, formatPercentWith
- Netx: Netx.java (Test)
- isIPV4, isIPV6, isMacAddress, getLocalIPAddress, getLocalIPV4Address, getExternalIPV4AddressFrom,
- getExternalIPV4AddressFromSohu, getExternalIPV4Address, getCityFromSohu, getCity, ipStringToLong,
- ipLongToString, matchMimeType, guessFileName, guessFileNameFromContentDisposition,
- guessFileNameFromUrl
- Premisex: Premisex.java (Test) | Premisex.kt (Test)
- require, check, requireNotNull, checkNotNull
- Rangex: Rangex.java (Test) | Rangex.kt (Test)
- rangeTo, until, downTo, requireInRange, requireNotInRange, in, notIn,
- reversed, step, coerceAtLeast, coerceAtMost, coerceIn
- DateRangex: DateRangex.java (Test) | DateRangex.kt (Test)
- [Year, Month...]RangeTo, [Year, Month...]Until, [Year, Month...]DownTo, reversed, step
- Reflectx: Reflectx.java (Test) | Reflectx.kt (Test)
- getDeclaredFieldRecursive, getDeclaredFieldsRecursive, getFieldValue, getStaticFieldValue,
- setFieldValue, setStaticFieldValue, getDeclaredMethodRecursive, getDeclaredMethodsRecursive,
- callMethod, callStaticMethod, getDeclaredConstructorRecursive, getDeclaredConstructorsRecursive,
- getClassHierarchy, isTypeArray, isTypeCollection
- Regexx: Regexx.java (Test) | Regexx.kt (Test)
- matches, find, lookingAt, getFirst, getAll, firstGroup, allGroup, replaceFirst, replaceAll, IPV4, IPV6,
- MAC_ADDRESS, CHINESE, CHINESE_SYMBOL, BLANK, EMAIL, URI, FLOAT_NUMBER, INTEGER
- ResourcesCacheHelper: ResourcesCacheHelper.java (Test)
- getFile, getDir, getResourcesDir
- MessageDigestx: MessageDigestx.java (Test) | MessageDigestx.kt (Test)
- getDigest, getMD5, getMD5_16, getSHA1, getSHA256, getSHA512
- Sequencex: Sequencex.java | [Sequencex.kt]
- joinToArrayString, asSequence, asIterable, sequenceOf, emptySequence, constrainOnce,
- generateSequence, flatten, contains, elementAt, elementAtOrElse, elementAtOrNull, find,
- findLast, first, firstOrNull, indexOf, indexOfFirst, indexOfLast, last, lastIndexOf,
- lastOrNull, single, singleOrNull, drop, dropWhile, filter, filterIndexed, filterIndexedTo,
- filterIsInstance, filterIsInstanceTo, filterNot, filterNotNull, filterNotNullTo, filterNotTo,
- filterTo, take, takeWhile, sorted, sortedBy, sortedByDescending, sortedWith, associate,
- associateBy, associateByTo, associateTo, toCollection, toMutableList, toMutableSet, toHashSet,
- toSortedSet, toMap, flatMap, flatMapOfIterable, flatMapOfIterableTo, flatMapTo, flatMapIndexed,
- flatMapIndexedOfIterable, flatMapIndexedOfIterableTo, flatMapIndexedTo, groupBy, groupByTo, map,
- withIndex, mapIndexedNotNull, mapIndexedNotNullTo, mapIndexedTo, mapNotNull, mapNotNullTo, mapTo,
- withIndex, distinct, distinctBy, all, any, count, fold, foldIndexed, forEach,
- forEachIndexed, onEach, onEachIndexed, maxOrNull, maxByOrNull, maxWithOrNull, maxOf, maxOfOrNull,
- maxOfWith, maxOfWithOrNull, minOrNull, minByOrNull, minWithOrNull, minOf, minOfOrNull, minOfWith,
- minOfWithOrNull, none, reduce, reduceIndexed, sumBy, sumByDouble, sumOf, requireNoNulls, chunked,
- minus, minusElement, partition, plus, plusElement, windowed, zip, unzip, joinTo, joinToString, averageOf
- Assertx: Assertx.java (Test) | Assertx.kt (Test)
- assertTwoEquals, assertAllNull, assertAllNotNull, assertThrow, assertNoThrow, assertTwoThrow, assertTwoNoThrow
- Zipx: Zipx.java (Test) | Zipx.kt (Test)
- compress, decompress, gzipCompress, gzipDecompress, compressFilesTo, compressFilesTo,
- compressFileTo, compressFile, compressChildFileTo, compressChildFile, decompressTo,
- decompress, getCompressDstFile, getDecompressDstDir, getTrueSize, listEntry, listEntryName, size
Please view the CHANGELOG.md file
Copyright (C) 2020 panpf <panpfpanpf@outlook.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.