用這種方法試試,逐個讀取文件並寫入一個文件。 下方爲了解您的簡單代碼。試試這個,我希望它能爲你工作。 您可以改進此代碼。
InputStream in1 = new FileInputStream("sourceLocation1");
InputStream in2 = new FileInputStream("sourceLocation2");
InputStream in3 = new FileInputStream("sourceLocation3");
InputStream in4 = new FileInputStream("sourceLocation4");
OutputStream out = new FileOutputStream("targetLocation");
// Copy the bits from instream to outstream
byte[] buf = new byte[1024];
int len;
while ((len = in1.read(buf)) > 0) {
out.write(buf, 0, len);
}
while ((len = in2.read(buf)) > 0) {
out.write(buf, 0, len);
}
while ((len = in3.read(buf)) > 0) {
out.write(buf, 0, len);
}
while ((len = in4.read(buf)) > 0) {
out.write(buf, 0, len);
}
in1.close();
in2.close();
in3.close();
in4.close();
out.close();
它是一個純文本文件(或類似的東西)? – matt5784 2012-07-06 17:52:05
它可以是任何東西!主要是mp3文件 – don 2012-07-06 19:28:30
@ user1122359得到了什麼解決方案? – 2015-03-18 08:18:26