FileOutputStream fos = new FileOutputStream( "c:\test.txt "); String nextLine = System.getProperty( "line.separator "); String testStr = "abcd "+nextLine+ "efgh "+nextLine+ "igkl "; byte[] c = testStr.getBytes(); fos.write(c); fos.close();