how to solve this task. If I try to create a file like Lion.avi. the last Point "." dissapears. The Validator says "the outputstream must be closed", but i closed it in line 39. Help please 😇
package de.codegym.task.task18.task1825;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
/*
Eine Datei aufbauen
*/
public class Solution {
public static void main(String[] args) throws IOException {
// C:\Users\vince\Desktop\Lion.avi.part1
int length = 0;
List<Byte> byteList = new ArrayList<>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
// Einlesen der Daten und einfügen in byte - Arraylist
while (true){
String fileName = reader.readLine();
if (fileName.equals("end")) {
String name = "C:\\Users\\vince\\Desktop\\Lion.avi.";
// Schreiben aller bytes in die datei ohne Endung und Beenden der Schleife
FileOutputStream outputStream = new FileOutputStream(name);
byte[] buffer = new byte[byteList.size()];
for (int i=0; i< buffer.length; i++){
buffer[i] = byteList.get(i);
}
outputStream.write(buffer, 0, buffer.length);
outputStream.close();
break;
}
FileInputStream inputStream = new FileInputStream(fileName);
if (inputStream.available() > 0){
byte[] buffer = new byte[inputStream.available()];
int count = inputStream.read(buffer);
length += buffer.length;
for (byte b : buffer)
byteList.add(b);
}
inputStream.close();
}
}
}