Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
72e42815
Commit
72e42815
authored
14 years ago
by
brinn
Browse files
Options
Downloads
Patches
Plain Diff
add: implement missing methods readUTF() and writeUTF()
fix: method readUnsignedShort() SVN: 19746
parent
86375d37
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/source/java/ch/systemsx/cisd/common/filesystem/ByteBufferRandomAccessFile.java
+23
-13
23 additions, 13 deletions
...sx/cisd/common/filesystem/ByteBufferRandomAccessFile.java
with
23 additions
and
13 deletions
common/source/java/ch/systemsx/cisd/common/filesystem/ByteBufferRandomAccessFile.java
+
23
−
13
View file @
72e42815
...
@@ -16,8 +16,10 @@
...
@@ -16,8 +16,10 @@
package
ch.systemsx.cisd.common.filesystem
;
package
ch.systemsx.cisd.common.filesystem
;
import
java.io.UnsupportedEncodingException
;
import
java.nio.ByteBuffer
;
import
java.nio.ByteBuffer
;
import
ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel
;
import
ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked
;
import
ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked
;
/**
/**
...
@@ -162,8 +164,7 @@ public class ByteBufferRandomAccessFile implements IRandomAccessFile
...
@@ -162,8 +164,7 @@ public class ByteBufferRandomAccessFile implements IRandomAccessFile
public
int
readUnsignedByte
()
throws
IOExceptionUnchecked
public
int
readUnsignedByte
()
throws
IOExceptionUnchecked
{
{
final
byte
b
=
buf
.
get
();
return
buf
.
get
()
&
0xff
;
return
(
b
<
0
)
?
256
+
b
:
b
;
}
}
public
short
readShort
()
throws
IOExceptionUnchecked
public
short
readShort
()
throws
IOExceptionUnchecked
...
@@ -173,8 +174,7 @@ public class ByteBufferRandomAccessFile implements IRandomAccessFile
...
@@ -173,8 +174,7 @@ public class ByteBufferRandomAccessFile implements IRandomAccessFile
public
int
readUnsignedShort
()
throws
IOExceptionUnchecked
public
int
readUnsignedShort
()
throws
IOExceptionUnchecked
{
{
final
short
s
=
buf
.
get
();
return
buf
.
getShort
()
&
0xffff
;
return
(
s
<
0
)
?
65536
+
s
:
s
;
}
}
public
char
readChar
()
throws
IOExceptionUnchecked
public
char
readChar
()
throws
IOExceptionUnchecked
...
@@ -210,12 +210,17 @@ public class ByteBufferRandomAccessFile implements IRandomAccessFile
...
@@ -210,12 +210,17 @@ public class ByteBufferRandomAccessFile implements IRandomAccessFile
throw
new
UnsupportedOperationException
();
throw
new
UnsupportedOperationException
();
}
}
/**
public
String
readUTF
()
* @throws UnsupportedOperationException
*/
public
String
readUTF
()
throws
UnsupportedOperationException
{
{
throw
new
UnsupportedOperationException
();
try
{
final
byte
[]
strBuf
=
new
byte
[
readUnsignedShort
()];
buf
.
get
(
strBuf
);
return
new
String
(
strBuf
,
"UTF-8"
);
}
catch
(
UnsupportedEncodingException
ex
)
{
throw
CheckedExceptionTunnel
.
wrapIfNecessary
(
ex
);
}
}
}
public
void
write
(
int
b
)
throws
IOExceptionUnchecked
public
void
write
(
int
b
)
throws
IOExceptionUnchecked
...
@@ -293,12 +298,17 @@ public class ByteBufferRandomAccessFile implements IRandomAccessFile
...
@@ -293,12 +298,17 @@ public class ByteBufferRandomAccessFile implements IRandomAccessFile
}
}
}
}
/**
* @throws UnsupportedOperationException
*/
public
void
writeUTF
(
String
str
)
throws
UnsupportedOperationException
public
void
writeUTF
(
String
str
)
throws
UnsupportedOperationException
{
{
throw
new
UnsupportedOperationException
();
try
{
final
byte
[]
strBuf
=
str
.
getBytes
(
"UTF-8"
);
writeShort
(
strBuf
.
length
);
write
(
strBuf
);
}
catch
(
UnsupportedEncodingException
ex
)
{
throw
CheckedExceptionTunnel
.
wrapIfNecessary
(
ex
);
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment