Skip to content

Commit

Permalink
docs: FileUtils#read废弃
Browse files Browse the repository at this point in the history
  • Loading branch information
livk-cloud committed May 27, 2024
1 parent 5ce3cdd commit a37921e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
import java.nio.channels.FileChannel;
import java.nio.channels.ReadableByteChannel;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.stream.Collectors;
import java.util.zip.GZIPInputStream;
Expand Down Expand Up @@ -95,7 +97,11 @@ public boolean createNewFile(File file) throws IOException {
* @param file the file
* @return the string
* @throws IOException the io exception
* @deprecated use
* {@link org.springframework.util.StreamUtils#copyToString(InputStream, Charset)} or
* {@link FileCopyUtils#copyToString(Reader)}
*/
@Deprecated(since = "1.3.0", forRemoval = true)
public String read(File file) throws IOException {
try (BufferedReader reader = Files.newBufferedReader(file.toPath())) {
return reader.lines().collect(Collectors.joining("\n"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.livk.commons.jackson.util.JsonMapperUtils;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -70,12 +71,4 @@ void gzip() throws IOException {
}
}

@Test
void read() throws IOException {
File file = new ClassPathResource("input.json").getFile();
String json = FileUtils.read(file);
JsonNode result = JsonMapperUtils.readTree(file);
assertEquals(result, JsonMapperUtils.readTree(json));
}

}

0 comments on commit a37921e

Please sign in to comment.