簡體   English   中英

jcifs無法將新行寫入文本文件

[英]jcifs cannot write new line to text file

我正在將文件從android設備寫入Windows文件夾
所有內容均完整無缺,但我無法寫新行

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

    SmbFileOutputStream out = new SmbFileOutputStream(file,true);

我努力了 :

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();

但是似乎沒有任何效果,請提供幫助。

這就是我用新行寫文件的方式

                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();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM