1
1
package org .testng .reporters ;
2
2
3
3
import java .io .BufferedReader ;
4
- import java .io .BufferedWriter ;
5
- import java .io .File ;
6
- import java .io .FileInputStream ;
7
- import java .io .FileOutputStream ;
8
- import java .io .FileWriter ;
9
4
import java .io .IOException ;
10
5
import java .io .InputStream ;
11
6
import java .io .InputStreamReader ;
12
- import java .io .OutputStream ;
13
- import java .io .Reader ;
14
- import java .io .StringWriter ;
15
- import java .io .Writer ;
16
7
import java .nio .charset .StandardCharsets ;
17
8
import java .util .stream .Collectors ;
18
9
@@ -22,63 +13,9 @@ private Files() {
22
13
// defeat instantiation
23
14
}
24
15
25
- /** @deprecated - This method stands deprecated as of TestNG <code>7.6.0</code> */
26
- @ Deprecated
27
- public static String readFile (File f ) throws IOException {
28
- try (InputStream is = new FileInputStream (f )) {
29
- return readFile (is );
30
- }
31
- }
32
-
33
16
public static String readFile (InputStream is ) throws IOException {
34
17
return new BufferedReader (new InputStreamReader (is , StandardCharsets .UTF_8 ))
35
18
.lines ()
36
19
.collect (Collectors .joining ("\n " ));
37
20
}
38
-
39
- /** @deprecated - This method stands deprecated as of TestNG <code>7.6.0</code> */
40
- @ Deprecated
41
- public static void writeFile (String string , File f ) throws IOException {
42
- f .getParentFile ().mkdirs ();
43
- try (FileWriter fw = new FileWriter (f );
44
- BufferedWriter bw = new BufferedWriter (fw )) {
45
- bw .write (string );
46
- }
47
- }
48
-
49
- /** @deprecated - This method stands deprecated as of TestNG <code>7.6.0</code> */
50
- @ Deprecated
51
- public static void copyFile (InputStream from , File to ) throws IOException {
52
- if (!to .getParentFile ().exists ()) {
53
- to .getParentFile ().mkdirs ();
54
- }
55
-
56
- try (OutputStream os = new FileOutputStream (to )) {
57
- byte [] buffer = new byte [65536 ];
58
- int count = from .read (buffer );
59
- while (count > 0 ) {
60
- os .write (buffer , 0 , count );
61
- count = from .read (buffer );
62
- }
63
- }
64
- }
65
-
66
- /** @deprecated - This method stands deprecated as of TestNG <code>7.6.0</code> */
67
- @ Deprecated
68
- public static String streamToString (InputStream is ) throws IOException {
69
- if (is != null ) {
70
- Writer writer = new StringWriter ();
71
-
72
- char [] buffer = new char [1024 ];
73
- try (Reader reader = new BufferedReader (new InputStreamReader (is , StandardCharsets .UTF_8 ))) {
74
- int n ;
75
- while ((n = reader .read (buffer )) != -1 ) {
76
- writer .write (buffer , 0 , n );
77
- }
78
- }
79
- return writer .toString ();
80
- } else {
81
- return "" ;
82
- }
83
- }
84
21
}
0 commit comments