Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.nio.file.Files;
- public class L3_CopyBytes {
- public static void main(String[] args) throws IOException {
- // BufferedReader in = new BufferedReader(new FileReader("inputLab.txt"));
- File file = new File("D:\\FilesStreams\\Lab\\04. Java-Advanced-Files-and-Streams-Lab-Resources\\input.txt");
- byte[] bytes = Files.readAllBytes(file.toPath());
- Writer writer = new FileWriter("outputBytes.txt");
- OutputStream result = new FileOutputStream("outBytes1");
- for (byte b : bytes) {
- String outSymbol = String.valueOf(b);
- if (b == 32) {
- outSymbol = " ";
- result.write(b);
- } else if (b == 10) {
- outSymbol = System.lineSeparator();
- result.write(b);
- }else{
- for (int i = 0; i < outSymbol.length(); i++) {
- result.write(outSymbol.charAt(i));
- }
- }
- writer.write(outSymbol);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement