出于某种原因,此代码正在更改输入中的任何“\n”字符,并在新输出文件中将其替换为“\n\r”。我参考了几个网站,但仍然没有弄清楚..有人有想法吗?非常感谢!
Socket connectionSocket = sData.accept();
InputStream inputStream = connectionSocket.getInputStream();
BufferedInputStream inputBufferedStream = new BufferedInputStream(inputStream);
FileOutputStream outputStream = new FileOutputStream("/home/greg/1");
byte[] buffer = new byte[1024];
long count = 0;
int n = 0;
while ((n = inputBufferedStream.read(buffer))>=0) {
outputStream.write(buffer, 0, n);
count += n;
}
outputStream.close();
}