It depends on what best means for you. Productivity wise, don’t reinvent the wheel and use Apache Commons. Which is here FileUtils.readFileToByteArray(File input)
.
Related Posts:
- How do I create a file and write to it?
- Reading a plain text file in Java
- java.io.FileNotFoundException: the system cannot find the file specified
- How do I save a String to a text file using Java?
- Scanner vs. BufferedReader
- Java and Windows – error: illegal escape character
- Java read file and store text in an array
- Reading a .txt file using Scanner class in Java
- Java FileOutputStream Create File if not exists
- Error unable to access jarfile C:\Jar
- In laymans terms, what does ‘static’ mean in Java? [duplicate]
- Sort an array in Java
- Java String Split by “|”
- Could not reserve enough space for object heap
- java.lang.ClassNotFoundException: com.mysql.jdbc.Driver in Eclipse
- “Char cannot be dereferenced” error
- Difference between Inheritance and Composition
- Print ArrayList
- Unsupported major.minor version 52.0 [duplicate]
- What is a StringIndexOutOfBoundsException? How can I fix it?
- Non-static variable cannot be referenced from a static context
- How to get an enum value from a string value in Java
- Round a double to 2 decimal places [duplicate]
- Int division: Why is the result of 1/3 == 0?
- Given final block not properly padded
- What is Parse/parsing?
- Returning Arrays in Java
- java.lang.ClassCastException
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘MyController’:
- Can I multiply strings in Java to repeat sequences?
- Why does cache use Most Recently Used (MRU) algorithm as evict policy?
- javac not working in windows command prompt
- Java returns error “Cannot instantiate the type”
- How does a Breadth-First Search work when looking for Shortest Path?
- HashMap get/put complexity
- @Autowired – No qualifying bean of type found for dependency
- SSH library for Java
- Java ArrayList replace at specific index
- Exception in thread “main” java.lang.OutOfMemoryError: Java heap space
- What is the best math library to use with java?
- How to execute a https GET request from java
- How to use VisibleForTesting for pure JUnit tests
- Converting JSON to XML in Java
- Import a custom class in Java
- Default keystore file does not exist?
- The declared package does not match the expected package “”
- Sort a Map
by values - Is not an enclosing class Java
- FtpClient storeFile always return False
- Variable is accessed within inner class. Needs to be declared final
- Using NotNull Annotation in method argument
- How to implement infinity in Java?
- Java Does Not Equal (!=) Not Working?
- How to represent empty char in Java Character class
- Definition of a Java Container
- ‘Source code does not match the bytecode’ when debugging on a device
- Determining Day of the week using Zeller’s Congruence in Java
- How to fix the compiler error in this program?
- “The public type <
> must be defined in its own file” error in Eclipse [duplicate] - How to calculate the intersection of two sets?
- method does not override method in its superclass
- Adding a timer to my program (javafx)
- How to resolve “Syntax error on token “else”” in Java?
- java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 exception
- What does this expression language ${pageContext.request.contextPath} exactly do in JSP EL?
- Simulating Game of Craps in JAVA
- Creating random numbers with no duplicates
- How to create a popup window in javafx
- How to determine an object’s class?
- Division of integers in Java
- Consider this code: “int s = 20; int t = s++ + –s;”. What are the values of s and t?
- “\b” in Java – Windows implemented
- Error: package or namespace load failed for ‘rJava’
- Difference between regex [A-z] and [a-zA-Z]
- How can I convert a char to CharSequence?
- Problems Generating A Math.random Number, Either 0 or 1
- Suggestions needed: Effective Java to C source code converter
- Downloading a file from spring controllers
- Java Error Exception in thread “AWT-EventQueue-0” java.lang.StackOverflowError
- Write a program that reads an unspecified number of integers, determines pos, neg, total, average
- Parsing JSON string in Java
- java attempting to assign weaker access privilege error
- Getting a “no interface expected here” when I try to subclass ServiceConnection [duplicate]
- How to determine day of week by passing specific date?
- Python-like list comprehension in Java
- Can an int be null in Java?
- What’s the difference between HashSet and Set?
- Netbeans – Error: Could not find or load main class
- Eclipse IDE – Error: Build path specifies execution environment Java SE 1.7
- Why int[] a = new int[1] instead of just int a?
- ArithmeticException: “Non-terminating decimal expansion; no exact representable decimal result”
- When to use a Map instead of a List in Java?
- How do I replace a character in a string in Java?
- What’s so special about 0x7f?
- Java Swing setting JPanel Size
- how to use “tab space” while writing in text file
- Change Name of Import in Java, or import two classes with the same name
- set background color: Android
- Class JavaLaunchHelper is implemented in two places
- No Main class found in NetBeans