Start New Discussion within our Software Development Community

Hello, I am trying to write a simple updater program (in Java). A client would connect to the server, which would hand out any files it needs updated. One example would be updating a Java .class file. I have tried to just copy a class file, to see if that one works. It doesn't. In the following code, please assume BufferedReader is and PrintWriter os have been declared and are open.

while((num = is.read()) != -1){
	os.print((char)num);
}

Um, also, I am not sure what is.read() returns if there are no more characters. I just used -1 because it looked right and I think it is used most often in place of null for integers :cheesy:

Also, one thing to be noted is how the program doesn't work. The two files are very similar, but with some minute differences, like (when viewed through Notepad) a question mark here where a black box is on the other one. Otherwise, the two look the same.

Okay, I am sorry for posting in the first place, but I found a solution. Using FileOutputStream and FileInputStream, the individual bytes are copied and the files are the exact same.

This question has already been answered. Start a new discussion instead.