create JPEG/txt any type file which requires to be

2019-06-07 07:24发布

I want to create JPEG/TEXT/MP3 any type as per user requirement files which requires to be fixed size which will also give by user, e.g 500 KB,1 Mb whatever size and also on path in sdcard which will also provide by user. But I have no idea how to achieve that. Who can teach me how to make/create it??

1条回答
爷、活的狠高调
2楼-- · 2019-06-07 08:15

Yes It is possible.

I am using below code to achieve such things.

class Test {
     public static void main(String args[]) {
          try {
               RandomAccessFile f = new RandomAccessFile("t.txt", "rw");
               f.setLength(1073741824);// 1073741824 bytes = 1 GB
               f.write("Hello I am writing this file".getBytes());
               f.close();
          } catch (Exception e) {
               e.printStackTrace();
          }
     }
}
查看更多
登录 后发表回答