-
Notifications
You must be signed in to change notification settings - Fork 0
/
ByteIO.java
45 lines (38 loc) · 1.41 KB
/
ByteIO.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import java.awt.*;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Stream;
public class ByteIO {
public static void main(String[] args) throws IOException {
// Files.list(Paths.get(".")).forEach(System.out::println);
FileInputStream fileInputStream = new FileInputStream("1.txt");
// int word;
// while ((word = fileReader.read()) >0){
// System.out.print((char) word);
// }
//fileInputStream.skip(3);
// fileInputStream.markSupported();
// fileInputStream.reset();
FileOutputStream fileOutputStream = new FileOutputStream("1.txt");
char[] c = new String("Test").toCharArray();
byte[] cb = new byte[c.length]; int index = 0;
for (char a : c){
cb[index] = (byte) a;
index++;
}
fileOutputStream.write(cb);
fileOutputStream.flush();
//System.out.println(Arrays.toString(fileInputStream.readAllBytes()));
for (int e: fileInputStream.readAllBytes()) {
System.out.print((char)e);
}
// String s = new String(byteArray);
// System.out.println(s);
int[] intArr = {1,2,3};
//Arrays.stream(intArr).boxed().map(Object::toString).forEach(System.out::println);
//List.of(intArr).stream().forEach(System.out::println);
}
}