mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-10-29 19:57:28 +00:00
SPARK-2337 Use Files.write() to save bytes to file
Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
This commit is contained in:
parent
12721d9cfe
commit
2d7576eedd
@ -37,6 +37,7 @@ import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -285,9 +286,7 @@ public class ConversationHistoryPlugin implements Plugin {
|
||||
// Write out new File
|
||||
try {
|
||||
File conFile = new File(transcriptDir, "conversations.xml");
|
||||
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(conFile), StandardCharsets.UTF_8));
|
||||
out.write(builder.toString());
|
||||
out.close();
|
||||
Files.write(conFile.toPath(), builder.toString().getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
catch (IOException e) {
|
||||
Log.error(e);
|
||||
|
||||
@ -28,15 +28,13 @@ import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -122,9 +120,7 @@ public final class ChatTranscripts {
|
||||
// Write out new File
|
||||
try {
|
||||
transcriptFile.getParentFile().mkdirs();
|
||||
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(transcriptFile), StandardCharsets.UTF_8));
|
||||
out.write(builder.toString());
|
||||
out.close();
|
||||
Files.write(transcriptFile.toPath(), builder.toString().getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
catch (IOException e) {
|
||||
Log.error(e);
|
||||
|
||||
@ -56,6 +56,7 @@ import java.io.*;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
@ -759,9 +760,7 @@ public class VCardManager {
|
||||
|
||||
// write xml to file
|
||||
try {
|
||||
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(vcardFile), StandardCharsets.UTF_8));
|
||||
out.write(xml);
|
||||
out.close();
|
||||
Files.write(vcardFile.toPath(), xml.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
catch (IOException e) {
|
||||
Log.error(e);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user