60 511
Assignments Done
98,1%
Successfully Done
In April 2018

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
Expert's answer
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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions