This should work. Probably you forgot to call encfileout.flush()
.
However this is not the preferred way to write texts. You should wrap your output stream with PrintWriter
and enjoy its println()
methods:
PrintWriter writer = new PrintWriter(new OutputStreamWriter(encfileout, charset));
Alternatively you can use FileWriter
instead of FileOutputStream
from the beginning:
FileWriter fw = new FileWriter("myfile");
PrintWriter writer = new PrintWriter(fw);
Now just call
writer.println();
And do not forget to call flush()
and close()
when you finish your job.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…