-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadModLine.java
More file actions
46 lines (41 loc) · 927 Bytes
/
ReadModLine.java
File metadata and controls
46 lines (41 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import java.io.*;
/*
* @author Andrew Keyes
* Keyesandrew@live.com
*/
public class ReadModLine {
private BufferedInputStream fileIn;
private int endOfLine = -1;
public ReadModLine(BufferedInputStream fileIn) throws java.io.IOException{
this.fileIn = fileIn;
}
public String[] readLine() throws java.io.IOException{
String[] arrayOfLine = new String[600];
char[] arrayOfWord = new char[600];
int i = 0;
int j=0;
char ch = (char) fileIn.read();
if(endOfLine==(int)ch){
return null;
}
while(ch==' '){
ch=(char)fileIn.read();
}
while(ch!=System.lineSeparator().charAt(0)){
if(ch==' '||ch=='+'){
arrayOfLine[i] = new String(arrayOfWord);
i++;
j=0;
arrayOfWord = new char[600];
}
else{
arrayOfWord[j] = ch;
j++;
}
ch = (char)fileIn.read();
}
arrayOfLine[i] = new String(arrayOfWord);
ch = (char)fileIn.read();
return arrayOfLine;
}
}