我有以下文件有3列,我想阅读以下文件并存储ArrayList
,如何使用Scanner
或Buffer reader
阅读?
例如。
ArrayList<Integert>[][] M = new ArrayList[size][size]
M[1][859].add(1806476)
M[3][800].add(2131700)
M[3][800].add(2734107).. so one
A B C
1 859 [1806476]
3 800 "[2131700, 2734107, 2877209, 2877209]"
4 815 [2883211]
7 815 "[2429412, 2886810, 2886804]"
7 362 [2909301]
7 806 [89573]
7 853 [2182646]
8 800 "[2910937, 2836340, 2884417]"
答案 0 :(得分:0)
基本上您想将其存储在arrayList
中。您可以使用以下方法
创建一类字段
class Multi {
int a, b, c;
}
public void addrecords(int i, int j, int k) {
Multi multi = new Multi();
Multi.a = i;
Multi.b = j;
Multi.c = k;
records.add(Multi);
}
List<Multi> records;
//code goes here
答案 1 :(得分:0)
> x=read.spss("F:\\Google Drive\\Master\\Thesis\\Predictors.sav", use.value.labels=FALSE, to.data.frame=TRUE,
+ max.value.labels=FALSE, trim.factor.names=TRUE,
+ trim_values=TRUE, reencode=NA, use.missings=to.data.frame,
+ sub=".", add.undeclared.levels="sort",
+ duplicated.value.labels="append",
+ duplicated.value.labels.infix="_duplicated_")
> y=read.spss("F:\\Google Drive\\Master\\Thesis\\Response.sav", use.value.labels=FALSE, to.data.frame=TRUE,
+ max.value.labels=FALSE, trim.factor.names=TRUE,
+ trim_values=TRUE, reencode=NA, use.missings=to.data.frame,
+ sub=".", add.undeclared.levels="sort",
+ duplicated.value.labels="append",
+ duplicated.value.labels.infix="_duplicated_")
> fit=glmnet(x, y, family="mgaussian", alpha=1.0, weights=rep(1,26), offset=NULL, nlambda=100)
Error in mrelnet(x, is.sparse, ix, jx, y, weights, offset, alpha, nobs, :
(list) object cannot be coerced to type 'double'
当你将String解析为Integer时,加上try / catch块