File tree Expand file tree Collapse file tree 1 file changed +6
-10
lines changed
java/client/src/org/openqa/selenium Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change 18
18
package org .openqa .selenium ;
19
19
20
20
import java .io .File ;
21
- import java .io .FileOutputStream ;
22
21
import java .io .IOException ;
23
- import java .io .OutputStream ;
22
+ import java .nio .file .Files ;
23
+ import java .nio .file .Path ;
24
24
import java .util .Base64 ;
25
25
26
26
/**
@@ -85,15 +85,11 @@ public File convertFromPngBytes(byte[] data) {
85
85
86
86
private File save (byte [] data ) {
87
87
try {
88
- File tmpFile = File .createTempFile ("screenshot" , ".png" );
88
+ Path tmpFilePath = Files .createTempFile ("screenshot" , ".png" );
89
+ File tmpFile = tmpFilePath .toFile ();
89
90
tmpFile .deleteOnExit ();
90
-
91
- try (OutputStream stream = new FileOutputStream (tmpFile )) {
92
- stream .write (data );
93
- return tmpFile ;
94
- } catch (IOException e ) {
95
- throw new WebDriverException (e );
96
- }
91
+ Files .write (tmpFilePath , data );
92
+ return tmpFile ;
97
93
} catch (IOException e ) {
98
94
throw new WebDriverException (e );
99
95
}
You can’t perform that action at this time.
0 commit comments