Answer to Question #63003 in Java | JSP | JSF for jonney
write a complete method that reads binary file of strings and return the number of strings that are greater than 20 characters in length
1
2016-10-29T10:44:06-0400
package com.company;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class SmallBinaryFiles {
private final static String FILE_NAME = "here must be ur path to file";
public static void main(String... aArgs) throws IOException{
System.out.println(reader());
}
private static String reader() throws IOException {
SmallBinaryFiles binary = new SmallBinaryFiles();
byte[] bytes = binary.readSmallBinaryFile(FILE_NAME);
if (bytes.length > 20) {
return "size of file read in: " + bytes.length;
}
return "less than 20";
}
private byte[] readSmallBinaryFile(String aFileName) throws IOException {
Path path = Paths.get(aFileName);
return Files.readAllBytes(path);
}
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
JavaJSPJSF
Comments
Leave a comment