-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServerProcessor.java
More file actions
42 lines (36 loc) · 960 Bytes
/
ServerProcessor.java
File metadata and controls
42 lines (36 loc) · 960 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
/**
* This is a helping class that uses the string given by the server program
* as the file name. It then reads the contents of file as a string and passes
* the string to the server.
*/
import java.io.*;
import java.util.Scanner;
public class ServerProcessor {
StringBuffer buff;
BufferedReader br;
String line;
public String getContents(String fileName) {
buff = new StringBuffer();
try {
File openFile = new File(fileName);
File f = new File(fileName);
if (f.isFile()) {
System.out.println("filename ... " + fileName + " exits");
Scanner inFile = new Scanner(openFile);
while (inFile.hasNext()) {
line = inFile.nextLine();
System.out.println(line);
buff.append(line);
buff.append("\n");
}
inFile.close();
return buff.toString();
}
else {
System.out.println("filename ... " + fileName + " does NOT exit");
}
} catch (Exception e) {
}
return null;
}
} // End class