1 | package printing;
|
---|
2 |
|
---|
3 | /**
|
---|
4 | * Insert the type's description here.
|
---|
5 | * Creation date: (03/18/13 10:14:17 am)
|
---|
6 | * @author: greg
|
---|
7 | */
|
---|
8 | public class FileSize {
|
---|
9 | /**
|
---|
10 | * FileSize constructor comment.
|
---|
11 | */
|
---|
12 | public FileSize() {
|
---|
13 | super();
|
---|
14 | }
|
---|
15 | /**
|
---|
16 | * Insert the method's description here.
|
---|
17 | * Creation date: (03/18/13 10:14:28 am)
|
---|
18 | * @param args java.lang.String[]
|
---|
19 | */
|
---|
20 | public static void main(String[] args) {
|
---|
21 | FileSize f = new FileSize();
|
---|
22 | f.run();
|
---|
23 | }
|
---|
24 | /**
|
---|
25 | * Insert the method's description here.
|
---|
26 | * Creation date: (03/18/13 10:15:37 am)
|
---|
27 | */
|
---|
28 | public void run() {
|
---|
29 | String fname = "c:\\config.sys";
|
---|
30 | try {
|
---|
31 | java.io.File fl = new java.io.File(fname);
|
---|
32 | long flz = -1;
|
---|
33 | try {
|
---|
34 | flz = fl.length();
|
---|
35 | } catch (Exception e) {
|
---|
36 | System.out.println("File error getting length:" + e.toString());
|
---|
37 | }
|
---|
38 | System.out.println("File length:" + flz);
|
---|
39 | java.io.RandomAccessFile rf = new java.io.RandomAccessFile(fname, "r");
|
---|
40 | flz = -1;
|
---|
41 | try {
|
---|
42 | flz = rf.length();
|
---|
43 | } catch (Exception e) {
|
---|
44 | System.out.println("RandomAccessFile error getting length:" + e.toString());
|
---|
45 | }
|
---|
46 | System.out.println("RandomAccessFile length:" + flz);
|
---|
47 | rf.close();
|
---|
48 | } catch (Exception ee) {
|
---|
49 | System.out.println("error:" + ee);
|
---|
50 | }
|
---|
51 | }
|
---|
52 | }
|
---|