为什么System.out.println(e.getCause());给出null?并且可以像这样存储整个HashSet集合吗?
private void saving() throws IOException, ClassNotFoundException {
ObjectOutputStream out = null;
try {
out = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(dataFile)));
out.writeObject(c);
} catch (java.io.NotSerializableException e) {
System.out.println(e.getCause());
} finally {
out.close();
}
}
Run Code Online (Sandbox Code Playgroud)
用来printStackTrace()代替getCause()
java.io.NotSerializableException: Data$1
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
at java.util.HashSet.writeObject(HashSet.java:284)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:962)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
at Prozor.saving(Prozor.java:81)
at Prozor.actionPerformed(Prozor.java:57) …Run Code Online (Sandbox Code Playgroud) 我会很简短,我拥有的是什么
array=( one.a two.b tree.c four.b five_b_abc)
Run Code Online (Sandbox Code Playgroud)
我要这个
array=( two.b four.b five_b_abc )
Run Code Online (Sandbox Code Playgroud)
从这里 我发现了这个
# replace any array item matching "b*" with "foo"
array=( foo bar baz )
array=( "${array[@]/%b*/foo}" )
echo "${orig[@]}"$'\n'"${array[@]}"
Run Code Online (Sandbox Code Playgroud)
怎么这不起作用
array2=( ${array[@]//%^.p/})
Run Code Online (Sandbox Code Playgroud)
结果 array2=array
这会删除所有p
array2=(${array[@]/*p*/})
Run Code Online (Sandbox Code Playgroud)
结果 array2=( one.a tree.c )
我需要一个想法如何添加^ p(所有接受p),并得到我的解决方案
array2=(${array[@]/*^p*/}
Run Code Online (Sandbox Code Playgroud)
它是一个相当大的数组,大约10k元素,我需要这样做,我需要它尽可能快地与数据,所以请不要循环解决方案.
它关于 http://en.wikipedia.org/wiki/Parallel_(software)和非常丰富的联机帮助页http://www.gnu.org/software/parallel/man.html
(for x in `cat list` ; do
do_something $x
done) | process_output
Run Code Online (Sandbox Code Playgroud)
被这取代
cat list | parallel do_something | process_output
Run Code Online (Sandbox Code Playgroud)
我正试图在此实现这一点
while [ "$n" -gt 0 ]
do
percentage=${"scale=2;(100-(($n / $end) * 100))"|bc -l}}
#get url from line specified by n from file done1
nextUrls=`sed -n "${n}p" < done1`
echo -ne "${percentage}% $n / $end urls saved going to line 1. current: $nextUrls\r"
# function that gets links from the url
getlinks $nextUrls
#save n
echo …Run Code Online (Sandbox Code Playgroud) 当您通过终端安装或更新时,有些人可能已经发现在Ubuntu中
你得到一个类似的问题
"你有没有安装或删除包[Y/n]?"
当你按下输入时就像输入"Y"或"y"时一样
所以我想知道如何在bash中实现这一点这是我到目前为止所拥有的?
echo "question?[Y/n]"
read choose
if [ $choose ~= "Y" ] [ $choose ~= "y" ] [ $choose ~= "" ]
then
#code
fi
Run Code Online (Sandbox Code Playgroud) 当hinernate尝试将此类映射到MySQL数据库时
/*
*To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package projekat.entities;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.persistence.*;
import org.apache.tapestry5.beaneditor.NonVisual;
/**
*
* @author nikola
*/
@Entity
public class Student implements Serializable {
@Id
@NonVisual
@GeneratedValue(strategy = GenerationType.AUTO)
@Basic(optional = false)
private Long kljuc;
@Basic(optional = false)
private String ime;
@Basic(optional = false)
private String prezime;
@Basic(optional = false)
private Integer index;
@ManyToMany
private List<Grupa> grupaList = …Run Code Online (Sandbox Code Playgroud) bash ×3
arrays ×1
create-table ×1
element ×1
gnu ×1
hibernate ×1
if-statement ×1
java ×1
keyword ×1
loops ×1
mysql ×1
replace ×1
syntax-error ×1