摘要:
_1 表示访问元组第一个(下标为0)的元素 _2 表示访问元组第二个(下标为1)的元素 _3 表示访问元组第三个(下标为2)的元素 阅读全文
随笔分类 - scala
scala Option
2021-09-28 17:00 by ZealouSnesS, 17 阅读, 收藏, 编辑
摘要:
scala option 使用 match 语句的时候需要case掉所有可能,否则运行时会报 scala.MatchError 错误 阅读全文
scala 删除目录
2021-08-25 16:19 by ZealouSnesS, 145 阅读, 收藏, 编辑
摘要:
file io - Delete directories recursively in Java - Stack Overflow You should check out Apache's commons-io. It has a FileUtils class that will do what 阅读全文
scala 声明变量
2021-08-23 13:49 by ZealouSnesS, 265 阅读, 收藏, 编辑
摘要:
scala 中无论 val 还是 var,声明的时候都必须赋一个初值,不能仅声明,例如: var str:String val str: String 都会报错 block can not contain declarations 所以,必须赋给一个初值,如果实在在声明的时候尚不能确定变量的值,则应 阅读全文
scala 截取字符串
2021-08-23 11:20 by ZealouSnesS, 2379 阅读, 收藏, 编辑
摘要:
例如截取字符串前一万个字符 str.substring(0, 10000) 注意截取长度不能超过字符串长度,否则会抛异常,改进一下 str.substring(0, if (str.length > 10000) 10000 else str.length) 阅读全文
scala 字节数组转为字符串再转回字节数组
2021-08-05 15:30 by ZealouSnesS, 535 阅读, 收藏, 编辑
摘要:
直接用Array[Byte].toString() 然后 String.getBytes() 会有问题 应该用: str = Base64.getEncoder.encodeToString(arr) arr = Base64.getDecoder.decode(str) 阅读全文