Skip to content

Commit 4855c5e

Browse files
committed
wip
1 parent 8f7e8f6 commit 4855c5e

File tree

1 file changed

+25
-28
lines changed

1 file changed

+25
-28
lines changed

src/main/java/jnr/enxio/channels/NativeSocketChannel.java

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.nio.channels.SocketChannel;
2727
import java.nio.channels.spi.SelectorProvider;
2828

29-
import io.netty.buffer.ByteBufUtil;
3029
import jnr.constants.platform.Errno;
3130
import jnr.constants.platform.Shutdown;
3231

@@ -130,65 +129,63 @@ public SocketChannel shutdownOutput() throws IOException {
130129

131130
private static final int SHUT_RD = Shutdown.SHUT_RD.intValue();
132131
private static final int SHUT_WR = Shutdown.SHUT_WR.intValue();
133-
134-
public static String hexDump (ByteBuffer buf, String prefix)
135-
{
132+
133+
public static String hexDump(ByteBuffer buf, String prefix) {
136134
buf = buf.duplicate();
137-
StringWriter str = new StringWriter ();
138-
PrintWriter out = new PrintWriter (str);
135+
StringWriter str = new StringWriter();
136+
PrintWriter out = new PrintWriter(str);
139137
int i = 0;
140138
int len = buf.remaining();
141139
byte[] line = new byte[16];
142-
while (i < len)
143-
{
144-
if (prefix != null)
140+
while (i < len) {
141+
if (prefix != null) {
145142
out.print(prefix);
146-
out.print(formatInt (i, 16, 8));
143+
}
144+
out.print(formatInt(i, 16, 8));
147145
out.print(" ");
148146
int l = Math.min(16, len - i);
149147
buf.get(line, 0, l);
150148
String s = toHexString(line, 0, l, ' ');
151149
out.print(s);
152-
for (int j = s.length(); j < 49; j++)
150+
for (int j = s.length(); j < 49; j++) {
153151
out.print(' ');
154-
for (int j = 0; j < l; j++)
155-
{
152+
}
153+
for (int j = 0; j < l; j++) {
156154
int c = line[j] & 0xFF;
157-
if (c < 0x20 || c > 0x7E)
155+
if (c < 0x20 || c > 0x7E) {
158156
out.print('.');
159-
else
157+
} else {
160158
out.print((char) c);
159+
}
161160
}
162161
out.println();
163162
i += 16;
164163
}
165164
return str.toString();
166165
}
167-
168-
public static String formatInt(int i, int radix, int len)
169-
{
166+
167+
public static String formatInt(int i, int radix, int len) {
170168
String s = Integer.toString(i, radix);
171169
StringBuffer buf = new StringBuffer();
172-
for (int j = 0; j < len - s.length(); j++)
170+
for (int j = 0; j < len - s.length(); j++) {
173171
buf.append("0");
172+
}
174173
buf.append(s);
175174
return buf.toString();
176175
}
177-
178-
public static String toHexString(byte[] buf, int off, int len, char sep)
179-
{
176+
177+
public static String toHexString(byte[] buf, int off, int len, char sep) {
180178
StringBuffer str = new StringBuffer();
181-
for (int i = 0; i < len; i++)
182-
{
183-
str.append(HEX.charAt(buf[i+off] >>> 4 & 0x0F));
184-
str.append(HEX.charAt(buf[i+off] & 0x0F));
185-
if (i < len - 1)
179+
for (int i = 0; i < len; i++) {
180+
str.append(HEX.charAt(buf[i + off] >>> 4 & 0x0F));
181+
str.append(HEX.charAt(buf[i + off] & 0x0F));
182+
if (i < len - 1) {
186183
str.append(sep);
184+
}
187185
}
188186
return str.toString();
189187
}
190188

191-
192189
static final String HEX = "0123456789abcdef";
193190

194191

0 commit comments

Comments
 (0)