0

我正在将一个文件从 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();

但似乎没有一个工作,请帮助。

4

1 回答 1

1

这就是我用新行编写文件的方式

                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();
于 2013-12-09T03:35:33.503 回答