一个IO处理库
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 2 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 1 年前 | ||
| 3 年前 | ||
| 2 年前 | ||
| 1 年前 | ||
| 1 年前 |
以下内容由 AI 翻译,如有问题请 点此提交 issue 反馈
![]()
io4cj是HttpClient的基础IO组件库,作为仓颉IO库的功能延伸,它让数据访问、存储与处理更高效便捷。其核心设计理念围绕source(数据源)与sink(数据汇)展开,分别对应仓颉框架中的InputStream与OutputStream。
核心能力
-
🚀 缓冲处理
-
💪 加密解密
-
💪 哈希计算
-
💪 数据流转
-
💪 GZIP压缩
-
💪 DEFLATE压缩/解压
发展蓝图
![]()
架构示意图
源代码结构
.
├── README.md
├── doc
│ ├── assets
│ ├── cjcov
│ ├── design.md
│ └── feature_api.md
├── src
│ ├── asyncTimeout.cj
│ ├── buffer.cj
│ ├── buffered_sink.cj
│ ├── buffered_source.cj
│ ├── byte_string.cj
│ ├── deflater_sink.cj
│ ├── exception.cj
│ ├── forwarding_sink.cj
│ ├── forwarding_source.cj
│ ├── forwarding_timeout.cj
│ ├── gzip_sink.cj
│ ├── gzip_source.cj
│ ├── hashing_sink.cj
│ ├── hashing_source.cj
│ ├── inflater_source.cj
│ ├── okio.cj
│ ├── PeekSource.cj
│ ├── pipe.cj
│ ├── pushable_timeout.cj
│ ├── RealBufferedSink.cj
│ ├── RealBufferedSource.cj
│ ├── segment_pool.cj
│ ├── segment.cj
│ ├── sink.cj
│ ├── SocketStream.cj
│ ├── source.cj
│ ├── timeout.cj
│ ├── utf8.cj
│ └── util.cj
└── test
│ ├── HLT
│ ├── LLT
│ └── UT
├── CHANGELOG.md
├── LICENSE.txt
├── .gitignore
├── README.md
└── README.OpenSource
doc包含库的设计文档、使用文档以及 LLT 覆盖率报告(1. io4cj 中存在包内可见的私有实现类,成员函数调用仅限于包内可见函数,外部 LLT 测试用例无法调用;2. io4cj 启用 spawn 时,LLT 测试用例覆盖不足,导致覆盖率未达 90%)。src为库的源代码目录test存放 HLT 测试用例、LLT 自测用例及 UT 单元测试用例
接口说明
核心类与成员函数详解,请参阅 feature_api
![]()
编译
提供两种编译方式
功能演示
import std.io.*
import std.time.*
import std.fs.*
import io4cj.*
main() {
var file = File("demo.txt", OpenOption.Create(true))
Okio.buffer(Okio.sink(file))
.writeUtf8("abcdefghijklmn \n")
.writeUtf8("中国 \n")
.writeUtf8("1234")
.close();
file = File("demo.txt", OpenOption.Open(true, true))
let bufferedSource = Okio.buffer(Okio.source(file));
println(bufferedSource.readUtf8Line())
println(bufferedSource.readUtf8Line())
println(bufferedSource.readUtf8Line())
}
Execution results are as follows:
abcdefghijklmn
中国
1234
File Copy Example
import std.io.*
import std.time.*
import io4cj.*
main() {
let a = Time.now().unixNano() / 1000000 // 计算开始时间
let file = File("apache-tomcat-8.5.81.rar", Read, Open)
let bs = ByteString.read(file, file.length)
var file2 = File("apache-tomcat-8.5.81-2.rar", Write, ForceCreate)
bs.write(file2)
let b = Time.now().unixNano() / 1000000 // 计算结束时间
println(b)
println(a)
println(b-a)
}
Execution results are as follows:
1663827401063
1663827401032
31
Verified in the following versions:
Cangjie Version: 1.0.0
Open Source License
This project is licensed under the Apache License 2.0. Feel free to enjoy and contribute to open source.
![]()
We welcome your PRs, issues, and any form of contribution.