Package net.n1da.dev.euler.helper
Class IO
- java.lang.Object
-
- net.n1da.dev.euler.helper.IO
-
public class IO extends java.lang.Object
Helper class for all standard i/o methods.- Since:
- 08.04.2015 10:27:40
- Author:
- Nico Danneberg
-
-
Constructor Summary
Constructors Modifier Constructor Description private
IO()
No instances wanted!
-
Method Summary
Modifier and Type Method Description static void
debug(java.lang.String msg)
Offers a simple way to print out a debug message.static void
debugln(java.lang.String msg)
Usesdebug(String)
with an additional "\n" at the end.static java.lang.String
i2s(int value)
Transforms a given primitive integer into astring
.static void
info(java.lang.String msg)
Offers a simple way to print out an info message.static void
infoln(java.lang.String msg)
Usesinfo(String)
with an additional "\n" at the end.static java.lang.String
join(int[] arr, java.lang.String glue)
Joins all elements of the given array to aString
and uses the glue as separator.static java.lang.String
join(long[] arr, java.lang.String glue)
Joins all elements of the given array to aString
and uses the glue as separator.static java.lang.String
join(java.lang.Object[] arr, java.lang.String glue)
Joins all elements of the given array to aString
and uses the glue as separator.static java.lang.String
l2s(long value)
Transforms a given primitive long into astring
.static byte[]
readBytes(java.lang.String file, java.lang.String sep)
Tries to read one line of byte values split by the given separatorstatic short[]
readDigits(java.lang.String file, int max)
Tries to read the given number of digits from the given file.static LargeNumber[]
readLargeNumbers(java.lang.String file, int max)
Reads the wanted number oflarge numbers
from the given file.static java.lang.String[]
readSortedStrings(java.lang.String file)
Reads all strings from the given file sorting them while reading directly.static java.lang.String[]
readStrings(java.lang.String file)
Reads all lines from the given file and creates an array with one entry per line.static java.util.ArrayList<java.lang.Integer[]>
readTriangle(java.lang.String file)
Reads integer values from the given text file in a triangle form.
-
-
-
Method Detail
-
debug
public static void debug(java.lang.String msg)
Offers a simple way to print out a debug message. Internally the print method ofSystem.err
is used.- Parameters:
msg
- - the message to be displayed
-
debugln
public static void debugln(java.lang.String msg)
Usesdebug(String)
with an additional "\n" at the end.- Parameters:
msg
- - the message to be displayed with a newline at the end
-
info
public static void info(java.lang.String msg)
Offers a simple way to print out an info message. Internally the print method ofSystem.out
is used.- Parameters:
msg
- - the message to be displayed
-
infoln
public static void infoln(java.lang.String msg)
Usesinfo(String)
with an additional "\n" at the end.- Parameters:
msg
- - the message to be displayed with a newline at the end
-
i2s
public static java.lang.String i2s(int value)
Transforms a given primitive integer into astring
.- Parameters:
value
- - the integer number to be transformed- Returns:
- the string representation of the given integer
-
l2s
public static java.lang.String l2s(long value)
Transforms a given primitive long into astring
.- Parameters:
value
- the long number to be transformed- Returns:
- the string representation of the given long
-
join
public static java.lang.String join(int[] arr, java.lang.String glue)
Joins all elements of the given array to aString
and uses the glue as separator.- Parameters:
arr
- the source integer listglue
- the string that will be placed between the elements- Returns:
- one string of with all elements
-
join
public static java.lang.String join(long[] arr, java.lang.String glue)
Joins all elements of the given array to aString
and uses the glue as separator.- Parameters:
arr
- the source integer listglue
- the string that will be placed between the elements- Returns:
- one string of with all elements
-
join
public static java.lang.String join(java.lang.Object[] arr, java.lang.String glue)
Joins all elements of the given array to aString
and uses the glue as separator.- Parameters:
arr
- the source object listglue
- the string that will be placed between the elements- Returns:
- one string of with all elements
-
readBytes
public static byte[] readBytes(java.lang.String file, java.lang.String sep)
Tries to read one line of byte values split by the given separator- Parameters:
file
- the file to read fromsep
- the separator between the values- Returns:
- an array of byte values
-
readDigits
public static short[] readDigits(java.lang.String file, int max)
Tries to read the given number of digits from the given file. Any exception is caught and results in a null return.- Parameters:
file
- the file to read frommax
- the maximum number of digits to read- Returns:
- an array of digits
-
readLargeNumbers
public static LargeNumber[] readLargeNumbers(java.lang.String file, int max)
Reads the wanted number oflarge numbers
from the given file.- Parameters:
file
- the file to read frommax
- the maximum number to read in- Returns:
- an array of
large numbers
-
readSortedStrings
public static java.lang.String[] readSortedStrings(java.lang.String file)
Reads all strings from the given file sorting them while reading directly.- Parameters:
file
- the file to read from- Returns:
- a sorted array of strings
-
readStrings
public static java.lang.String[] readStrings(java.lang.String file)
Reads all lines from the given file and creates an array with one entry per line.- Parameters:
file
- the file to read from- Returns:
- an array of strings
-
readTriangle
public static java.util.ArrayList<java.lang.Integer[]> readTriangle(java.lang.String file)
Reads integer values from the given text file in a triangle form.- Parameters:
file
- the file to read from- Returns:
- an
ArrayList
ofInteger
arrays
-
-