Answer to Question #63003 in Java | JSP | JSF for jonney

Question #63003
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
Expert's answer
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS