| Index: editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/io/FileUtilities.java
|
| diff --git a/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/io/FileUtilities.java b/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/io/FileUtilities.java
|
| index c6e67d9498343fe6d24fd03450cd5eb322d01469..1a491a8520a2529ffabae2588e61af2780cd1d4b 100644
|
| --- a/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/io/FileUtilities.java
|
| +++ b/editor/tools/plugins/com.google.dart.tools.core/src/com/google/dart/tools/core/utilities/io/FileUtilities.java
|
| @@ -13,6 +13,8 @@
|
| */
|
| package com.google.dart.tools.core.utilities.io;
|
|
|
| +import com.google.common.io.CharStreams;
|
| +
|
| import java.io.BufferedReader;
|
| import java.io.BufferedWriter;
|
| import java.io.File;
|
| @@ -240,34 +242,25 @@ public class FileUtilities {
|
| * @throws IOException if the file contents could not be read
|
| */
|
| public static String getContents(File file) throws IOException {
|
| - FileReader fileReader = null;
|
| - try {
|
| - fileReader = new FileReader(file);
|
| - BufferedReader reader = new BufferedReader(fileReader);
|
| - return getContents(reader);
|
| - } finally {
|
| - if (fileReader != null) {
|
| - fileReader.close();
|
| - }
|
| - }
|
| + Reader fileReader = new FileReader(file);
|
| + BufferedReader reader = new BufferedReader(fileReader);
|
| + return getContents(reader);
|
| }
|
|
|
| /**
|
| - * Return the contents of the given reader, interpreted as a string. The client is responsible for
|
| - * closing the reader.
|
| + * Return the contents of the given reader, interpreted as a string. The {@link Reader} will be
|
| + * closed.
|
| *
|
| * @param reader the reader whose contents are to be returned
|
| * @return the contents of the given reader, interpreted as a string
|
| * @throws IOException if the reader could not be read
|
| */
|
| public static String getContents(Reader reader) throws IOException {
|
| - StringBuilder builder = new StringBuilder();
|
| - int nextChar = reader.read();
|
| - while (nextChar >= 0) {
|
| - builder.append((char) nextChar);
|
| - nextChar = reader.read();
|
| + try {
|
| + return CharStreams.toString(reader);
|
| + } finally {
|
| + reader.close();
|
| }
|
| - return builder.toString();
|
| }
|
|
|
| /**
|
|
|