public static DataOutputStream getMainOutputStream(String fileName, boolean overwrite) throws ClassFileLoaderException
    {
        File file = new File(fileName);
        
        if (file.exists())
        {
            if (overwrite)
            {
                 file.delete();
            }
            else
            {
                throw new ClassFileLoaderException("Файл \"" + fileName + "\" уже существует.");
            }
        }
        
        if (file.isDirectory())
            throw new ClassFileLoaderException("Can't save file as directory");
        
        try
        {
            file.createNewFile();
        } 
        catch (IOException ex)
        {
           throw new ClassFileLoaderException(ex);
        }
        
        if (!file.canWrite())
            throw new ClassFileLoaderException("Can't write to " + fileName);
        
        java.io.FileOutputStream outputStream;
        try 
        {
            outputStream = new java.io.FileOutputStream(file);
        } 
        catch (FileNotFoundException ex) 
        {
            throw new ClassFileLoaderException(ex);
        }
        return new java.io.DataOutputStream(outputStream);
    }