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:
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();
}
}
}