简体   繁体   中英

jcifs cannot write new line to text file

I'm writing a file from android device to windows folder
all contents are intact but i'm not able to write a new line

    NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(null,nam,p);
    file = new SmbFile(url, auth);

    SmbFileOutputStream out = new SmbFileOutputStream(file,true);

I have tried :

out.write(("next"+ "\n" + text).getBytes());               
out.write(("next"+String.format("%n") + text).getBytes());
out.write(("next"+System.getProperty("line.separator") + text).getBytes());         
out.flush();
out.close();

But none seems to work, please help.

this is how I did to write file with new line

                Date now = new Date();
                String strDateFormat = "EEEE, MMMM dd, yyyy HH:mm:ss";
                SimpleDateFormat sdf = new SimpleDateFormat(strDateFormat);
                String txtVal = "INFO\t" + usr + "\t" + sdf.format(now) + "\t" +count +"\t"+"Ver.1";            
                NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("XXXX", "XXXXX", "XXXXXX");
                String path = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
                SmbFile sFile = new SmbFile(path, auth);
                //SmbFileOutputStream sfos = new SmbFileOutputStream(sFile);

                SmbFileOutputStream sfos = new SmbFileOutputStream(sFile, true);                

                sfos.write((txtVal+"\r\n").getBytes());               
                sfos.close();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM