Skip to content

Commit 235fe74

Browse files
authored
Merge pull request #43 from oracle/Issue#-41,42-Additions-to-facilitate-the-weblogic-deploy-testing-project
Added writeInputStr…
2 parents 994e200 + 224a742 commit 235fe74

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

core/src/main/java/oracle/weblogic/deploy/util/FileUtils.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.io.ByteArrayOutputStream;
88
import java.io.File;
99
import java.io.FileInputStream;
10+
import java.io.FileOutputStream;
1011
import java.io.FilenameFilter;
1112
import java.io.IOException;
1213
import java.io.InputStream;
@@ -593,6 +594,24 @@ public static byte[] readInputStreamToByteArray(InputStream input) throws IOExce
593594
return outputStream.toByteArray();
594595
}
595596

597+
public static File writeInputStreamToFile(InputStream input, String fileName) throws IOException {
598+
FileOutputStream fos = null;
599+
File file = null;
600+
601+
try {
602+
File tmpdir = new File(System.getProperty("java.io.tmpdir"));
603+
file = new File(tmpdir, fileName);
604+
byte[] byteArray = FileUtils.readInputStreamToByteArray(input);
605+
fos = new FileOutputStream(file);
606+
fos.write(byteArray);
607+
}
608+
finally {
609+
if (fos != null) { fos.close(); }
610+
}
611+
612+
return file;
613+
}
614+
596615
///////////////////////////////////////////////////////////////////////////
597616
// Private helper methods //
598617
///////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)