Skip to content

Commit 68bb18c

Browse files
committed
FileIO に abailableなread追加
1 parent 0815407 commit 68bb18c

File tree

5 files changed

+37
-11
lines changed

5 files changed

+37
-11
lines changed

.github/workflows/maven-publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717

1818
steps:
1919
- uses: actions/checkout@v2
20-
- name: Set up JDK 11
20+
- name: Set up JDK 1.8
2121
uses: actions/setup-java@v2
2222
with:
23-
java-version: '11'
23+
java-version: '1.8'
2424
distribution: 'temurin'
2525
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
2626
settings-path: ${{ github.workspace }} # location for the settings.xml file

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ JSONまではほどほどに使えますが、他は実験感覚で作ってい
2828
<dependency>
2929
<groupId>net.siisise</groupId>
3030
<artifactId>softlib</artifactId>
31-
<version>1.1.7</version>
31+
<version>1.1.8</version>
3232
<type>jar</type>
3333
</dependency>
3434
~~~
3535
時々変わることがあるので特定バージョンを指定するか、SoftLibJSONなど使用したい機能経由で指定するのがおすすめです。
3636

37-
リリース版 1.1.7 ぐらい。
38-
次版 1.1.8-SNAPSHOT
37+
リリース版 1.1.8 ぐらい。
38+
次版 1.1.9-SNAPSHOT
3939

4040
~~~
4141
<version>[1.1.4,)</version>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>net.siisise</groupId>
55
<artifactId>softlib</artifactId>
6-
<version>1.1.7</version>
6+
<version>1.1.8</version>
77
<packaging>jar</packaging>
88
<name>SoftLib</name>
99
<description>Java simple API Packet io, base64, etc...</description>

src/main/java/net/siisise/io/FileIO.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ public static byte[] binRead(InputStream in) throws IOException {
6464
return pac.toByteArray();
6565
}
6666

67+
/**
68+
* Socket等ブロックしない程度に読む.
69+
* @param in
70+
* @return
71+
* @throws IOException
72+
*/
73+
public static byte[] readAvailablie(InputStream in) throws IOException {
74+
Packet pac = new PacketA();
75+
available(in,pac.getOutputStream());
76+
return pac.toByteArray();
77+
}
78+
6779
/**
6880
* inとoutを繋ぐだけ
6981
* @param in
@@ -85,6 +97,20 @@ public static int io(InputStream in, OutputStream out) throws IOException {
8597
return size;
8698
}
8799

100+
public static int available(InputStream in, OutputStream out) throws IOException {
101+
byte[] data = new byte[102400];
102+
int len = in.available();
103+
int flen = 0;
104+
while ( len > 0) {
105+
int s = in.read(data);
106+
if ( s < 0 ) break;
107+
out.write(data, 0, s);
108+
flen += s;
109+
len = in.available();
110+
}
111+
return flen;
112+
}
113+
88114
/**
89115
*
90116
* @param in

src/main/java/net/siisise/lang/CodePoint.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,20 +119,20 @@ public static int utf8(FrontPacket pac) {
119119
int len;
120120
int min;
121121
int srd = rd;
122-
if (rd < 0x80) { // 0xxx xxxx 1バイト 7bit 00 - 7f
122+
if (rd < 0x80) { // 0xxx xxxx 00 - 7F 1バイト 7bit 00 - 7f
123123
return rd;
124-
} else if (rd < 0xc0) { // 10xx xxxx 80 - 7ff 2バイト目以降
124+
} else if (rd < 0xc0) { // 10xx xxxx 80 - BF 80 - 7ff 2バイト目以降
125125
pac.backWrite(rd);
126126
return -1;
127-
} else if (rd < 0xe0) { // 110x xxxx 2バイト 11bit
127+
} else if (rd < 0xe0) { // 110x xxxx C0 - DF 2バイト 11bit
128128
rd &= 0x1f;
129129
len = 1;
130130
min = 0x80;
131-
} else if (rd < 0xf0) { // 1110 xxxx 3バイト 16bit
131+
} else if (rd < 0xf0) { // 1110 xxxx E0 - EF 3バイト 16bit
132132
rd &= 0xf;
133133
len = 2;
134134
min = 0x800;
135-
} else { // 1111 0xxx 4バイト 21bit
135+
} else { // 1111 0xxx F0 - F7 4バイト 21bit
136136
rd &= 0x7;
137137
len = 3;
138138
min = 0x10000;

0 commit comments

Comments
 (0)