MCPcopy Index your code
hub / github.com/dumbledore/AlbiteREADER / seek

Method seek

src/org/albite/io/RandomReadingFile.java:107–141  ·  view source on GitHub ↗

Seeks to the specified position @param position @throws IllegalArgumentException if the position argument is wrong, i.e.: position < 0 or RandomReadingFile#length() <= position @throws IOException if an IOException occurred

(final int position)

Source from the content-addressed store, hash-verified

105 * @throws IOException if an IOException occurred
106 */
107 public final void seek(final int position) throws IOException {
108
109 if (position == pointer) {
110 return;
111 }
112
113 if (position < 0 || position >= length()) {
114 throw new IllegalArgumentException(
115 "Trying to seek outside file's contents");
116 }
117
118 final int pos;
119
120 if (position < pointer) {
121 /*
122 * Must go back, i.e. it's necessary to reopen the input stream
123 */
124
125 /*
126 * Close input before reopening it
127 */
128 if (in != null) {
129 in.close();
130 }
131
132 in = file.openDataInputStream();
133 pos = position;
134 } else {
135 pos = position - pointer;
136 }
137
138 skipBytes(pos);
139
140 pointer = position;
141 }
142
143 public final long skip(long n) throws IOException {
144 return skipBytes((int) n);

Callers 3

RandomReadingFileMethod · 0.95
loadMethod · 0.45
getDefinitionMethod · 0.45

Calls 4

lengthMethod · 0.95
skipBytesMethod · 0.95
closeMethod · 0.45
openDataInputStreamMethod · 0.45

Tested by

no test coverage detected