From 4de67b497e0e229fe4a42f66f833640b6e50fd5a Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Sun, 17 Nov 2024 13:45:44 +0200 Subject: Moved the project to an IDEA project & wrote part of README.txt --- src/main/scala/utils.scala | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 src/main/scala/utils.scala (limited to 'src/main/scala/utils.scala') diff --git a/src/main/scala/utils.scala b/src/main/scala/utils.scala deleted file mode 100644 index cfca568..0000000 --- a/src/main/scala/utils.scala +++ /dev/null @@ -1,28 +0,0 @@ -package o1game.utils - -import java.io.InputStream - -/** Converts this string to an array of bytes (probably for transmission). - * - * @param str the string to convert - * @return an array of bytes representing the string in UTF8. - */ -def stringToByteArray(str: String): Array[Byte] = - str.toVector.map(_.toByte).toArray - -/** Reads n characters from the given InputStream blockingly. - * - * @param input the InputStream to read from - * @param n the number of bytes to read - * @return The read result, or None in case of failure - */ -def getNCharsFromSocket(input: InputStream, n: Int): Option[String] = - val buffer: Array[Byte] = Array.ofDim(n) - var i = 0 - var failed = false - while i < n && !failed do - val res = input.read(buffer, i, n - i) - if res < 0 then failed = true - i += res - // TODO: better error handling - if failed then None else Some(String(buffer)) -- cgit v1.2.3