Advertisement
kijato

List<String> vs byte[]

Sep 23rd, 2019
458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. import java.io.IOException;
  2. import java.nio.charset.Charset;
  3. import java.nio.file.Files;
  4. import java.nio.file.Paths;
  5. import java.util.List;
  6.  
  7. public class m2 {
  8.  
  9.     static public void main( String args[] ) throws Exception
  10.     {
  11.         try {
  12.             String filename = "C:\\Temp\\beanshell-DAT.java\\dat_xxx.dat";
  13.            
  14.             System.out.println(Files.size(Paths.get(filename)));
  15.            
  16.             List<String> lines = Files.readAllLines(Paths.get(filename), Charset.forName("Cp1250"));
  17.             System.out.println(lines.size()+" "+lines.toString().length());
  18.            
  19.             byte[] bytes = Files.readAllBytes(Paths.get(filename));
  20.             System.out.println(bytes.length);
  21.            
  22.             System.out.print("Press ENTER..."); System.in.read();
  23.        }
  24.        catch (IOException e) {
  25.             e.printStackTrace();
  26.        }
  27.     }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement