Thanks for the reply Stan, thought it would be rude to just throw in loads of code without an introduction!! I've used the code button...
I guess the error is on the outfile printwriter, but can I see it? The file is created, but nothing is written.
import java.net.*;
import java.io.*;
public class libraryServer {
public static FileOutputStream outStream;
public static PrintWriter outFile;
public static void main(
String[] args) throws IOException {
ServerSocket serverSocket = null;
try {
serverSocket = new ServerSocket(4444);
} catch (IOException e) {
System.err.println("Could not listen on port: 4444.");
System.exit(1);
}
Socket clientSocket = null;
try {
clientSocket = serverSocket.accept();
} catch (IOException e) {
System.err.println("Accept failed.");
System.exit(1);
}
outStream= new FileOutputStream("hamish.txt");
outFile = new PrintWriter(clientSocket.getOutputStream(),true);
BufferedReader in = new BufferedReader(new InputStreamReader(
clientSocket.getInputStream()));
String inputLine, outputLine;
libraryProtocol kkp = new libraryProtocol();
outputLine = kkp.processInput(null);
outFile.println(outputLine);
while ((inputLine = in.readLine()) != null) {
outputLine = kkp.processInput(inputLine);
outFile.println(outputLine);
if (outputLine.equals("Bye."))
break;
}
in.close();
outFile.close();
clientSocket.close();
serverSocket.close();
}
}