io - Writing to a text file issue Java -
i coding function check if file cq.txt exists , if so, read it. have been having issue have declared printwriter outside of while loop. later in application, supposed write question 1: correct or question 2: correct file. but, not. creates text file when check it, shows empty. here code, thank in advance: package receiverhost; import java.io.*; import java.net.*; public class receiverhost { public static void main(string[] args) throws exception { //set socket on port 5000 serversocket server = new serversocket(5000); //set "cookie"/ text file written to/ read writer db = new bufferedwriter(new outputstreamwriter(new fileoutputstream("cq.txt"), "utf-8")); system.out.println("tcpserver waiting client on port 5000"); while(true){ //declare string fromclient string fromclient; socket connected = server.accept(); system.out.println(" client" + " " + connec...