X-Git-Url: http://gitweb.fperrin.net/?p=DictionaryPC.git;a=blobdiff_plain;f=src%2Fcom%2Fhughes%2Futil%2FFileUtil.java;h=d280cc1a232e8e2798b5e57e6e25ec0d59689b73;hp=d3024da18947d68cecf06930a3acaf7ae81efda1;hb=85b485359fd98ffb8dabe84cf0c70c1016eff0e5;hpb=31218ade21839194c5cbbf7e5238f3013b4b196f diff --git a/src/com/hughes/util/FileUtil.java b/src/com/hughes/util/FileUtil.java index d3024da..d280cc1 100644 --- a/src/com/hughes/util/FileUtil.java +++ b/src/com/hughes/util/FileUtil.java @@ -1,67 +1,67 @@ -// Copyright 2011 Google Inc. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package com.hughes.util; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.PrintStream; -import java.io.RandomAccessFile; -import java.util.ArrayList; -import java.util.List; - -@SuppressWarnings("WeakerAccess") -public final class FileUtil { - public static String readLine(final RandomAccessFile file, final long startPos) throws IOException { - file.seek(startPos); - return file.readLine(); - } - - public static List readLines(final File file) throws IOException { - final List result = new ArrayList<>(); - try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file)))) { - String line; - while ((line = in.readLine()) != null) { - result.add(line); - } - } - return result; - } - - public static String readToString(final File file) throws IOException { - StringBuilder result = new StringBuilder(); - try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file)))) { - String line; - while ((line = in.readLine()) != null) { - result.append(line).append("\n"); - } - } - return result.toString(); - } - - public static void writeStringToUTF8File(final String string, final File file) { - throw new IllegalStateException(); - } - - public static void printString(final File file, final String s) throws IOException { - final PrintStream out = new PrintStream(new FileOutputStream(file)); - out.print(s); - out.close(); - } - -} +// Copyright 2011 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.hughes.util; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintStream; +import java.io.RandomAccessFile; +import java.util.ArrayList; +import java.util.List; + +@SuppressWarnings("WeakerAccess") +public final class FileUtil { + public static String readLine(final RandomAccessFile file, final long startPos) throws IOException { + file.seek(startPos); + return file.readLine(); + } + + public static List readLines(final File file) throws IOException { + final List result = new ArrayList<>(); + try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file)))) { + String line; + while ((line = in.readLine()) != null) { + result.add(line); + } + } + return result; + } + + public static String readToString(final File file) throws IOException { + StringBuilder result = new StringBuilder(); + try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file)))) { + String line; + while ((line = in.readLine()) != null) { + result.append(line).append("\n"); + } + } + return result.toString(); + } + + public static void writeStringToUTF8File(final String string, final File file) { + throw new IllegalStateException(); + } + + public static void printString(final File file, final String s) throws IOException { + final PrintStream out = new PrintStream(new FileOutputStream(file)); + out.print(s); + out.close(); + } + +}