MCPcopy Index your code
hub / github.com/apache/groovy / read

Method read

src/main/java/groovy/io/LineColumnReader.java:97–127  ·  view source on GitHub ↗

Reads a single character. @return The character read, as an integer in the range 0 to 65535 (0x00-0xffff), or -1 if the end of the stream has been reached

()

Source from the content-addressed store, hash-verified

95 * or -1 if the end of the stream has been reached
96 */
97 @Override
98 public int read() throws IOException {
99 if (newLineWasRead) {
100 line += 1;
101 column = 1;
102 newLineWasRead = false;
103 }
104
105 int charRead = super.read();
106 if (charRead > -1) {
107 char c = (char)charRead;
108 // found a \r or \n, like on Mac or Unix
109 // could also be Windows' \r\n
110 if (c == '\r' || c == '\n') {
111 newLineWasRead = true;
112 if (c == '\r') {
113 mark(1);
114 c = (char)super.read();
115 // check if we have \r\n like on Windows
116 // if it's not \r\n we reset, otherwise, the \n is just consumed
117 if (c != '\n') {
118 reset();
119 }
120 }
121 } else {
122 column += 1;
123 }
124 }
125
126 return charRead;
127 }
128
129 /**
130 * Reads characters into a portion of an array.

Callers 2

readLineMethod · 0.95
skipMethod · 0.95

Calls 3

markMethod · 0.95
resetMethod · 0.95
readMethod · 0.65

Tested by

no test coverage detected