日期:2014-05-20 浏览次数:20882 次
BufferedInputStream in = null;
BufferedOutputStream out = null;
try {
in = new BufferedInputStream(new FileInputStream(FILENAME));
out = new BufferedOutputStream(new FileOutputStream(FILEOUT));
byte[] buff = new byte[60];
int cnt = in.read(buff, 0, 60);
for (int i =0; i < cnt; ++i) {
String val = Byte.toString(buff[i]);
out.write(Byte.valueOf(val, 10));
}
} finally {
if (null != in)
in.close();
if (null != out)
out.close();
}
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileChannel.MapMode;
public class Test_13 {
public static void main(String[] args) throws IOException {
File binFile = new File("D:\\tmp\\libbc-south-shared.so");
File outFile = new File("d:\\tmp\\out.txt");
FileChannel ch = new FileInputStream(binFile).getChannel();
BufferedWriter out = new BufferedWriter(new FileWriter(outFile));
MappedByteBuffer buff = ch.map(MapMode.READ_ONLY, 0, binFile.length());
while(buff.remaining()>=4){
int data = buff.getInt();
out.write(String.valueOf(data));
out.write("\t");
}
out.flush();
ch.close();
out.close();
System.out.println(Integer.MAX_VALUE);
System.out.println(String.valueOf(Integer.MAX_VALUE).length());
}
}