File: file2binArraySrc.java

package info (click to toggle)
cadencii 3.3.9%2Bsvn20110818.r1732-5
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 35,880 kB
  • sloc: cs: 160,836; java: 42,449; cpp: 7,605; ansic: 1,728; perl: 1,087; makefile: 236; php: 142; xml: 117; sh: 21
file content (23 lines) | stat: -rw-r--r-- 710 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.io.*;
import com.boare.corlib.*;

class file2binArraySrc{
    public static void main( String[] args ){
        if( args.length < 2 ){
            return;
        }
        try{
            File file = new File( args[0] );
            int length = (int)file.length();
            FileInputStream in = new FileInputStream( file );
            StreamWriter out = new StreamWriter( args[1] );
            out.write( "String data = \"" );
            byte[] buf = new byte[length];
            in.read( buf, 0, length );
            out.writeLine( Base64.encode( buf ) + "\";" );
            in.close();
            out.close();
        }catch( Exception ex ){
        }
    }
}