java - BufferedWriter write() method not working -


when check "dir" directory, file created (with name writtenfile1), nothing gets written inside , not understand why.

is common pitfall bufferedwriter? because code looks reasonable.

    int = 1;     path path = paths.get("dir//writtenfile" + + ".txt");     charset charset = charset.defaultcharset();     try {         bufferedwriter writer = files.newbufferedwriter(path, charset);         writer.write("message written!");         //writer.write("this file number " + i);     } catch (exception e) {         system.out.println(e);     } 

as name bufferedwriter implies, data buffered. or last part written on explicitly flushing or closing writer instance.

this not bug; normal behaviour of class.


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -