@@ -113,8 +113,8 @@ static <T> UnixStream<T> from(final Stream<T> stream) {
113
113
* @return an UnixStream with file names of the current directory.
114
114
* @throws IOException thrown if an error occurs during reading the current directory
115
115
*/
116
- static UnixStream <String > ls () throws IOException {
117
- return ls (Paths .get ("" ). toFile (). getAbsolutePath () );
116
+ static UnixStream <Path > ls () throws IOException {
117
+ return ls (Paths .get ("" ));
118
118
}
119
119
120
120
/**
@@ -124,22 +124,18 @@ static UnixStream<String> ls() throws IOException {
124
124
* @return an UnixStream with file names of the given directory.
125
125
* @throws IOException thrown if an error occurs during reading the directory
126
126
*/
127
- static UnixStream <String > ls (final String directory ) throws IOException {
127
+ static UnixStream <Path > ls (final Path directory ) throws IOException {
128
128
Objects .requireNonNull (directory , "The directory must not be null" );
129
- File [] files = new File (directory ).listFiles ();
130
- if (files != null ) {
131
- return new UnixStreamImpl <>(Arrays .stream (files ).map (File ::getName ));
132
- }
133
- return new UnixStreamImpl <>(Stream .empty ());
129
+ return new UnixStreamImpl <>(Files .list (directory ));
134
130
}
135
131
136
132
/**
137
133
* Create a new UnixStream with the absolute path of the current directory.
138
134
*
139
135
* @return a new UnixStream with the absolute path of the current directory.
140
136
*/
141
- static UnixStream <String > pwd () {
142
- return new UnixStreamImpl <>(Stream .of (Paths .get ("" ). toFile (). getAbsolutePath () ));
137
+ static UnixStream <Path > pwd () {
138
+ return new UnixStreamImpl <>(Stream .of (Paths .get ("" )));
143
139
}
144
140
145
141
0 commit comments