小编Avn*_*esh的帖子

无法使用Firefox下载blob文件,但它可以在Chrome中运行吗?

这是我的下载代码:

var mimeType = this.getMime(obj);
var ab = this.base64ToArrayBuffer(obj[key]);
var blob = new Blob([ab.buffer], {
    type : mimeType
});
var result = this.bintostring(blob);
var url = window.URL.createObjectURL(blob);
var a = document.createElement('a');
a.href = url;
a.download = result.filename;
a.target = '_blank';
a.click();
window.URL.revokeObjectURL(url);
Run Code Online (Sandbox Code Playgroud)

在调试过程中,我没有看到任何异常.

javascript firefox mozilla google-chrome

6
推荐指数
1
解决办法
3413
查看次数

Ljava.lang.Object; 无法转换为[Ljava.lang.Integer

我编写了一个泛型类,下面是该类的构造函数.我想做这样的事情就像写在线一样

elements = (E[])new Object[size] 
Run Code Online (Sandbox Code Playgroud)

因为我不知道运行时的泛型类型因此会抛出异常.

public class Stack<E> implements IStack<E> {
protected E[] elements = null;
protected int top = -1;
protected int size= 0;
private static final int DEFAULT_CAPACITY = 10;

public Stack(){
    this(DEFAULT_CAPACITY);
}

public Stack(int size){
    if(size <0){
        throw new IllegalArgumentException("Initial capacity cannot be negative or zero");
    }
    ArrayList<Integer> ar = new ArrayList<Integer>();
    elements = (E[])new Object[size];
}
}
Run Code Online (Sandbox Code Playgroud)

有什么方法可以解决这些问题吗?E的声明是

protected E[] elements = null;    
Run Code Online (Sandbox Code Playgroud)

这就是我试图打电话的方式

Random ran = new Random();
Stack<Integer> st = new Stack<Integer>(); …
Run Code Online (Sandbox Code Playgroud)

java generics

3
推荐指数
2
解决办法
1万
查看次数

标签 统计

firefox ×1

generics ×1

google-chrome ×1

java ×1

javascript ×1

mozilla ×1