本帖最后由 黑马刘涛 于 2012-7-19 14:32 编辑
- package com.itcast.test;
- import java.io.*;
- public class PrintDemo {
- /**
- * @param args
- */
- public static void main(String[] args) throws Exception {
- // TODO Auto-generated method stub
- BufferedInputStream bufis =
- new BufferedInputStream(new FileInputStream("G:\\KuGou\\周华健 - 刀剑如梦.mp3"));
- PrintStream out = new PrintStream(new FileOutputStream("C:\\Users\\shandawang\\Desktop\\a.txt"),true);
- byte[] buf = new byte[1024];
- int len = 0;
- while((len = bufis.read(buf,0,1024)) != -1)
- {
- out.write(buf,0,len);
- //out.flush();
- }
- out.close();
- bufis.close();
- }
- }
复制代码 我要将一个音乐媒体文件的二进制数据转换成1010001这样的字符串写到一个文本文件中该怎么做?上面的代码只是做了一个复制的工作。 |
|