作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
// Open bin file for writing:
String s = "Hello";
FileOutputStream binOutput = new FileOutputStream("out.txt");
byte[] b;
b = s.getBytes();
binOutput.write(b);
binOutput.close();
上面的代码是从 java servlet 页面运行的之后,我检查了“out.txt”,但它仍然是空的。这似乎是一项微不足道的任务。我错过了什么?
最佳答案
冲洗它:
binOutput.write(b);
binOutput.flush();
binOutput.close();
关于Java 将 byte[] 写入文件 - 空文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20534703/
我是一名优秀的程序员,十分优秀!