Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
smileNicky
taoshop
提交
31d21788
T
taoshop
项目概览
smileNicky
/
taoshop
通知
4
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
2
Wiki
1
Wiki
分析
仓库
DevOps
项目成员
Pages
T
taoshop
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
1
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
31d21788
编写于
2月 17, 2019
作者:
N
nicky
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
原型模式测试类
上级
3147acaa
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
36 addition
and
29 deletion
+36
-29
src/taoshop-portal/src/test/java/com/muses/taoshop/Attachment.java
...op-portal/src/test/java/com/muses/taoshop/Attachment.java
+3
-2
src/taoshop-portal/src/test/java/com/muses/taoshop/Client.java
...aoshop-portal/src/test/java/com/muses/taoshop/Client.java
+15
-9
src/taoshop-portal/src/test/java/com/muses/taoshop/Email.java
...taoshop-portal/src/test/java/com/muses/taoshop/Email.java
+18
-18
未找到文件。
src/taoshop-portal/src/test/java/com/muses/taoshop/Attachment.java
浏览文件 @
31d21788
package
com.muses.taoshop
;
import
java.io.*
;
public
class
Attachment
public
class
Attachment
implements
Serializable
{
public
void
download
()
{
System
.
out
.
println
(
"下载附件"
);
System
.
out
.
println
(
"下载附件"
);
}
}
\ No newline at end of file
src/taoshop-portal/src/test/java/com/muses/taoshop/Client.java
浏览文件 @
31d21788
package
com.muses.taoshop
;
public
class
Client
{
public
static
void
main
(
String
a
[])
{
Email
email
,
copyEmail
;
Email
email
,
copyEmail
=
null
;
email
=
new
Email
();
copyEmail
=(
Email
)
email
.
clone
();
try
{
copyEmail
=(
Email
)
email
.
deepClone
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
System
.
out
.
println
(
"email==copyEmail?"
);
System
.
out
.
println
(
email
==
copyEmail
);
System
.
out
.
println
(
"email.getAttachment==copyEmail.getAttachment?"
);
System
.
out
.
println
(
email
.
getAttachment
()==
copyEmail
.
getAttachment
());
System
.
out
.
println
(
"email.getAttachment==copyEmail.getAttachment?"
);
System
.
out
.
println
(
email
.
getAttachment
()==
copyEmail
.
getAttachment
());
}
}
\ No newline at end of file
src/taoshop-portal/src/test/java/com/muses/taoshop/Email.java
浏览文件 @
31d21788
package
com.muses.taoshop
;
import
java.io.*
;
public
class
Email
implements
Clone
able
public
class
Email
implements
Serializ
able
{
private
Attachment
attachment
=
null
;
public
Email
()
{
this
.
attachment
=
new
Attachment
();
}
public
Object
clone
()
public
Object
deepClone
()
throws
IOException
,
ClassNotFoundException
,
OptionalDataException
{
Email
clone
=
null
;
try
{
clone
=(
Email
)
super
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
System
.
out
.
println
(
"Clone failure!"
);
}
return
clone
;
//将对象写入流中
ByteArrayOutputStream
bao
=
new
ByteArrayOutputStream
();
ObjectOutputStream
oos
=
new
ObjectOutputStream
(
bao
);
oos
.
writeObject
(
this
);
//将对象从流中取出
ByteArrayInputStream
bis
=
new
ByteArrayInputStream
(
bao
.
toByteArray
());
ObjectInputStream
ois
=
new
ObjectInputStream
(
bis
);
return
(
ois
.
readObject
());
}
public
Attachment
getAttachment
()
{
return
this
.
attachment
;
}
public
void
display
()
{
System
.
out
.
println
(
"查看邮件"
);
System
.
out
.
println
(
"查看邮件"
);
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录