Skip to content

Commit ebbb2cd

Browse files
committed
support NIO Path for printJob and sendDocument
1 parent 75e2c27 commit ebbb2cd

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/main/kotlin/de/gmuth/ipp/client/IppJob.kt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import java.io.File
1515
import java.io.FileInputStream
1616
import java.io.InputStream
1717
import java.net.URI
18+
import java.nio.file.Files
19+
import java.nio.file.Path
1820
import java.time.Duration
1921
import java.time.ZonedDateTime
2022
import java.util.logging.Level
@@ -264,7 +266,18 @@ class IppJob(
264266
documentName: String? = null,
265267
documentNaturalLanguage: String? = null,
266268
documentFormat: DocumentFormat? = null
267-
) = sendDocument(FileInputStream(file), lastDocument, documentName, documentNaturalLanguage, documentFormat)
269+
) =
270+
sendDocument(FileInputStream(file), lastDocument, documentName, documentNaturalLanguage, documentFormat)
271+
272+
@JvmOverloads
273+
fun sendDocument(
274+
path: Path,
275+
lastDocument: Boolean = true,
276+
documentName: String? = null,
277+
documentNaturalLanguage: String? = null,
278+
documentFormat: DocumentFormat? = null
279+
) =
280+
sendDocument(Files.newInputStream(path), lastDocument, documentName, documentNaturalLanguage, documentFormat)
268281

269282
//----------------------
270283
// Send-URI (depreacted)

src/main/kotlin/de/gmuth/ipp/client/IppPrinter.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import de.gmuth.ipp.core.IppTag.*
1616
import de.gmuth.ipp.iana.IppRegistrationsSection2
1717
import java.io.*
1818
import java.net.URI
19+
import java.nio.file.Files
20+
import java.nio.file.Path
1921
import java.time.Duration
2022
import java.time.Instant
2123
import java.time.Instant.now
@@ -430,6 +432,14 @@ open class IppPrinter(
430432
) =
431433
printJob(FileInputStream(file), attributeBuilders, notifyEvents)
432434

435+
@JvmOverloads
436+
fun printJob(
437+
path: Path,
438+
attributeBuilders: Collection<IppAttributeBuilder>,
439+
notifyEvents: List<String>? = null
440+
) =
441+
printJob(Files.newInputStream(path), attributeBuilders, notifyEvents)
442+
433443
// vararg signatures for convenience
434444

435445
@JvmOverloads

0 commit comments

Comments
 (0)