Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
netty-demo
提交
9537cfb6
N
netty-demo
项目概览
Kwan的解忧杂货铺@新空间代码工作室
/
netty-demo
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
netty-demo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
9537cfb6
编写于
4月 19, 2023
作者:
Kwan的解忧杂货铺@新空间代码工作室
🐭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:基础练习
上级
0e037396
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
81 addition
and
3 deletion
+81
-3
data.txt
data.txt
+1
-0
pom.xml
pom.xml
+10
-0
src/main/java/com/kwan/shuyu/heima/ByteBuffer_001_Write.java
src/main/java/com/kwan/shuyu/heima/ByteBuffer_001_Write.java
+1
-1
src/main/java/com/kwan/shuyu/heima/ByteBuffer_002_Read.java
src/main/java/com/kwan/shuyu/heima/ByteBuffer_002_Read.java
+1
-1
src/main/java/com/kwan/shuyu/heima/ByteBuffer_003_split.java
src/main/java/com/kwan/shuyu/heima/ByteBuffer_003_split.java
+1
-1
src/main/java/com/kwan/shuyu/heima/bytebuffer/ByteBuffer_001_Test.java
.../com/kwan/shuyu/heima/bytebuffer/ByteBuffer_001_Test.java
+28
-0
src/main/java/com/kwan/shuyu/heima/bytebuffer/ByteBuffer_002_Test.java
.../com/kwan/shuyu/heima/bytebuffer/ByteBuffer_002_Test.java
+38
-0
target/classes/com/kwan/shuyu/heima/bytebuffer/ByteBuffer_001_Write.class
...om/kwan/shuyu/heima/bytebuffer/ByteBuffer_001_Write.class
+0
-0
target/classes/com/kwan/shuyu/heima/bytebuffer/ByteBuffer_002_Read.class
...com/kwan/shuyu/heima/bytebuffer/ByteBuffer_002_Read.class
+0
-0
target/classes/com/kwan/shuyu/heima/bytebuffer/ByteBuffer_003_split.class
...om/kwan/shuyu/heima/bytebuffer/ByteBuffer_003_split.class
+0
-0
target/classes/word2.txt
target/classes/word2.txt
+1
-0
未找到文件。
data.txt
0 → 100644
浏览文件 @
9537cfb6
1234567890abc
\ No newline at end of file
pom.xml
浏览文件 @
9537cfb6
...
...
@@ -35,6 +35,16 @@
<artifactId>
lombok
</artifactId>
<version>
1.18.26
</version>
</dependency>
<dependency>
<groupId>
com.google.code.gson
</groupId>
<artifactId>
gson
</artifactId>
<version>
2.9.0
</version>
</dependency>
<dependency>
<groupId>
com.google.guava
</groupId>
<artifactId>
guava
</artifactId>
<version>
31.1-jre
</version>
</dependency>
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-api
</artifactId>
...
...
src/main/java/com/kwan/shuyu/heima/
bytebuffer/
ByteBuffer_001_Write.java
→
src/main/java/com/kwan/shuyu/heima/ByteBuffer_001_Write.java
浏览文件 @
9537cfb6
package
com.kwan.shuyu.heima
.bytebuffer
;
package
com.kwan.shuyu.heima
;
import
java.io.RandomAccessFile
;
import
java.nio.ByteBuffer
;
...
...
src/main/java/com/kwan/shuyu/heima/
bytebuffer/
ByteBuffer_002_Read.java
→
src/main/java/com/kwan/shuyu/heima/ByteBuffer_002_Read.java
浏览文件 @
9537cfb6
package
com.kwan.shuyu.heima
.bytebuffer
;
package
com.kwan.shuyu.heima
;
import
com.kwan.shuyu.until.ByteBufferUtil
;
...
...
src/main/java/com/kwan/shuyu/heima/
bytebuffer/
ByteBuffer_003_split.java
→
src/main/java/com/kwan/shuyu/heima/ByteBuffer_003_split.java
浏览文件 @
9537cfb6
package
com.kwan.shuyu.heima
.bytebuffer
;
package
com.kwan.shuyu.heima
;
/**
* 分割数据
...
...
src/main/java/com/kwan/shuyu/heima/bytebuffer/ByteBuffer_001_Test.java
0 → 100644
浏览文件 @
9537cfb6
package
com.kwan.shuyu.heima.bytebuffer
;
import
java.io.FileInputStream
;
import
java.nio.ByteBuffer
;
import
java.nio.channels.FileChannel
;
/**
* ByteBuffer读取文件内容
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2023/4/18 17:15
*/
public
class
ByteBuffer_001_Test
{
public
static
void
main
(
String
[]
args
)
{
try
(
FileChannel
channel
=
new
FileInputStream
(
"data.txt"
).
getChannel
())
{
ByteBuffer
buffer
=
ByteBuffer
.
allocate
(
10
);
channel
.
read
(
buffer
);
buffer
.
flip
();
while
(
buffer
.
hasRemaining
())
{
final
byte
b
=
buffer
.
get
();
System
.
out
.
println
((
char
)
b
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
src/main/java/com/kwan/shuyu/heima/bytebuffer/ByteBuffer_002_Test.java
0 → 100644
浏览文件 @
9537cfb6
package
com.kwan.shuyu.heima.bytebuffer
;
import
lombok.extern.slf4j.Slf4j
;
import
java.io.FileInputStream
;
import
java.nio.ByteBuffer
;
import
java.nio.channels.FileChannel
;
/**
* ByteBuffer读取文件内容,多次读取
*
* @author : qinyingjie
* @version : 2.2.0
* @date : 2023/4/18 17:15
*/
@Slf4j
public
class
ByteBuffer_002_Test
{
public
static
void
main
(
String
[]
args
)
{
try
(
FileChannel
channel
=
new
FileInputStream
(
"data.txt"
).
getChannel
())
{
ByteBuffer
buffer
=
ByteBuffer
.
allocate
(
10
);
while
(
true
)
{
final
int
len
=
channel
.
read
(
buffer
);
log
.
info
(
"read len {}"
,
len
);
if
(
len
==
-
1
)
{
//表示未读到数据
break
;
}
buffer
.
flip
();
//读模式
while
(
buffer
.
hasRemaining
())
{
final
byte
b
=
buffer
.
get
();
log
.
info
(
"实际字节 {}"
,
(
char
)
b
);
}
buffer
.
clear
();
//写模式
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
target/classes/com/kwan/shuyu/heima/bytebuffer/ByteBuffer_001_Write.class
已删除
100644 → 0
浏览文件 @
0e037396
文件已删除
target/classes/com/kwan/shuyu/heima/bytebuffer/ByteBuffer_002_Read.class
已删除
100644 → 0
浏览文件 @
0e037396
文件已删除
target/classes/com/kwan/shuyu/heima/bytebuffer/ByteBuffer_003_split.class
已删除
100644 → 0
浏览文件 @
0e037396
文件已删除
target/classes/word2.txt
浏览文件 @
9537cfb6
helloworld秦书予
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录