<@U0BLPSJAK> hey sorry to ping you directly I was ...
# ktor
o
@Deactivated User hey sorry to ping you directly I was running the TestBot with updated codebase and am having trouble trying to send a String through ByteWriteChannel
Copy code
output.writeByte(data.toByte())
Copy code
java.lang.NumberFormatException: For input string: "NICK BamBaka
"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:580)
	at java.lang.Byte.parseByte(Byte.java:149)
	at java.lang.Byte.parseByte(Byte.java:175)
	at com.github.otakusenpai.testbot.connection.BasicConnection$sendData$1.doResume(BasicConnection.kt:62)
	at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:42)
	at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.run(Dispatched.kt:168)
	at kotlinx.coroutines.experimental.DispatchedContinuation.run(Dispatched.kt:13)
	at kotlinx.coroutines.experimental.EventLoopBase.processNextEvent(EventLoop.kt:166)
	at kotlinx.coroutines.experimental.BlockingCoroutine.joinBlocking(Builders.kt:69)
	at kotlinx.coroutines.experimental.BuildersKt__BuildersKt.runBlocking(Builders.kt:45)
	at kotlinx.coroutines.experimental.BuildersKt.runBlocking(Unknown Source)
	at kotlinx.coroutines.experimental.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:35)
	at kotlinx.coroutines.experimental.BuildersKt.runBlocking$default(Unknown Source)
	at com.github.otakusenpai.testbot.connection.BasicConnection.sendData(BasicConnection.kt:61)
	at com.github.otakusenpai.testbot.MainKt$setConnection$1.doResume(main.kt:23)
	at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:42)
	at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.run(Dispatched.kt:168)
	at kotlinx.coroutines.experimental.DispatchedContinuation.run(Dispatched.kt:13)
	at kotlinx.coroutines.experimental.EventLoopBase.processNextEvent(EventLoop.kt:166)
	at kotlinx.coroutines.experimental.BlockingCoroutine.joinBlocking(Builders.kt:69)
	at kotlinx.coroutines.experimental.BuildersKt__BuildersKt.runBlocking(Builders.kt:45)
	at kotlinx.coroutines.experimental.BuildersKt.runBlocking(Unknown Source)
	at kotlinx.coroutines.experimental.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:35)
	at kotlinx.coroutines.experimental.BuildersKt.runBlocking$default(Unknown Source)
	at com.github.otakusenpai.testbot.MainKt.setConnection(main.kt:12)
	at com.github.otakusenpai.testbot.MainKt$main$one$1.doResume(main.kt:81)
	at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:42)
	at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.run(Dispatched.kt:168)
	at kotlinx.coroutines.experimental.DispatchedContinuation.run(Dispatched.kt:13)
	at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
And this
Copy code
java.lang.NumberFormatException: For input string: "USER BamBaka 0 * :BamBaka
"
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
	at java.lang.Integer.parseInt(Integer.java:580)
	at java.lang.Byte.parseByte(Byte.java:149)
	at java.lang.Byte.parseByte(Byte.java:175)
	at com.github.otakusenpai.testbot.connection.BasicConnection$sendData$1.doResume(BasicConnection.kt:62)
	at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:42)
	at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.run(Dispatched.kt:168)
	at kotlinx.coroutines.experimental.DispatchedContinuation.run(Dispatched.kt:13)
	at kotlinx.coroutines.experimental.EventLoopBase.processNextEvent(EventLoop.kt:166)
	at kotlinx.coroutines.experimental.BlockingCoroutine.joinBlocking(Builders.kt:69)
	at kotlinx.coroutines.experimental.BuildersKt__BuildersKt.runBlocking(Builders.kt:45)
	at kotlinx.coroutines.experimental.BuildersKt.runBlocking(Unknown Source)
	at kotlinx.coroutines.experimental.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:35)
	at kotlinx.coroutines.experimental.BuildersKt.runBlocking$default(Unknown Source)
	at com.github.otakusenpai.testbot.connection.BasicConnection.sendData(BasicConnection.kt:61)
	at com.github.otakusenpai.testbot.MainKt$setConnection$1.doResume(main.kt:24)
	at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:42)
	at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.run(Dispatched.kt:168)
	at kotlinx.coroutines.experimental.DispatchedContinuation.run(Dispatched.kt:13)
	at kotlinx.coroutines.experimental.EventLoopBase.processNextEvent(EventLoop.kt:166)
	at kotlinx.coroutines.experimental.BlockingCoroutine.joinBlocking(Builders.kt:69)
	at kotlinx.coroutines.experimental.BuildersKt__BuildersKt.runBlocking(Builders.kt:45)
	at kotlinx.coroutines.experimental.BuildersKt.runBlocking(Unknown Source)
	at kotlinx.coroutines.experimental.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:35)
	at kotlinx.coroutines.experimental.BuildersKt.runBlocking$default(Unknown Source)
	at com.github.otakusenpai.testbot.MainKt.setConnection(main.kt:12)
	at com.github.otakusenpai.testbot.MainKt$main$one$1.doResume(main.kt:81)
	at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:42)
	at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.run(Dispatched.kt:168)
	at kotlinx.coroutines.experimental.DispatchedContinuation.run(Dispatched.kt:13)
	at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
d
Looking at the stacktrace it seems that you are trying to convert a string into a byte. Is data a String?
o
yes
d
“127”.toByte()
would work, but obviously a normal string wont
o
ok, so how do i get the underlying data in the string to byte?
d
A string is a list of characters
A character cant be converted directly into a byte either
o
should i use ByteBuffer or some java api to convert the string to a ByteArray ?
d
There is the concept of Charset/Encoding
With a charset, for example utf8
You can encode a string into a bytearray and decode a bytearray into a string
And you can write all those bytes at once into a channel
o
Its not complete yet
👌 1
also i tried to change the autoconnect to freenode to get an input from the user