Clarification of FileOutputStream
Hello everyone, this is my first posting on this forums. I'm relatively new to Java, and wish to learn it more. I managed to make my own program with some tutorials and example programs found all over the Internet, however I'd like to understand better certain part of the code.
It's about file transfer, specifically writing into file from stream (server client communication over socket).
This part is clear, I know what does it do, but not sure how to explain it. But following part is more problematic.
ServerSocket server= new ServerSocket(4444);
Socket connection = server.accept();
If anyone have patience to explain it, line by line. I compiled program, and it does what it should do: from input stream he reads data until there is nothing to read, in steps of 1024 bytes, and write it test.txt at C drive. After that, it close the stream and file for writing. However, I'm lacking technical terms that would help me understand it.
File dataFile = new File("C:\test.txt");
FileOutputStream inputFile = new FileOutputStream(dataFile);
InputStream inps = connection.getInputStream();
BufferedInputStream input2 = new BufferedInputStream(inps, 1024);
byte buff = new byte;
int length = 0;
int count = 0;
while ((length = input2.read(buff, 0, 1024)) != -1)
count = count + 1024;
inputFile.write(buff, 0, length);
Is there any Java book I could look into, that someone could recommend for a beginner? It doesn't necessarily have to be online book, but it would make it easier to find in online library.
Thank you in advance.