Skip to content

Commit

Permalink
PCGenFrame.readTextFromFile: use Java 7/8/9 APIS to simplify (#4771)
Browse files Browse the repository at this point in the history
  • Loading branch information
grimreaper authored and karianna committed Dec 29, 2018
1 parent 2cc49dd commit 22d1986
Showing 1 changed file with 5 additions and 25 deletions.
30 changes: 5 additions & 25 deletions code/src/java/pcgen/gui2/PCGenFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@
import java.awt.event.ItemListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -1896,33 +1895,14 @@ public boolean showCustomSpellDialog(SpellBuilderFacade spellBuilderFI)

private static String readTextFromFile(String fileName)
{
String aString;
final File aFile = new File(fileName);

if (!aFile.exists())
{
Logging.errorPrint("Could not find license at " + fileName);
aString = LanguageBundle.getString("in_licNoInfo"); //$NON-NLS-1$

return aString;
}

try
{
BufferedReader theReader = new BufferedReader(new InputStreamReader(new FileInputStream(aFile), "UTF-8"));
final int length = (int) aFile.length();
final char[] inputLine = new char[length];
theReader.read(inputLine, 0, length);
theReader.close();
aString = new String(inputLine);
}
catch (IOException e)
return Files.readString(Paths.get(fileName));
} catch (IOException e)
{
Logging.errorPrint("Could not read license at " + fileName, e);
aString = "No license information found";
return LanguageBundle.getString("in_licNoInfo"); //$NON-NLS-1$
}

return aString;
}

/**
Expand Down

0 comments on commit 22d1986

Please sign in to comment.