tags)
@author 作者
(*多个作者使用多个@author标签标识,java
doc中显示按输入时间顺序罗列。)
例:*
@author Leo. Yao
@param 输入参数的名称 说明
适用范围:方法
例:* @param str
the String用来存放输出信息。
@return 输出参数说明
适用范围:方法
例: *
@return<code>true</code>执行成功
* <code>false</code>执行失败.
@since
JDK版本
用于标识编译该文件所需要的JDK环境。
适用范围:文件、类
例: * @since
JDK1.6
@version 版本号
用于标识注释对象的版本号
适用范围:文件、类、方法
例: * @version 1.0
@see 链接目标
表示参考。会在java 文档中生成一个超链接,链接到参考的类容。使用中的感觉是@see不需要包路径,对我这种懒人比较喜欢,相对{@link
}这种既要加大括号,有需要包路径,我还是选择偷懒,当然你要是不介意使用import导入要link的类,那就可以达到@see的效果,所以总体来说,还是选择@see,当然两个在特殊场合下还是用法不一样的
用法:
@see
#field
@see #Constructor(Type,
Type...)
@see #Constructor(Type id, Type
id...)
@see #method(Type,
Type,...)
@see #method(Type id, Type,
id...)
@see
Class
@see
Class#field
@see Class#Constructor(Type,
Type...)
@see Class#Constructor(Type id,
Type id)
@see Class#method(Type,
Type,...)
@see Class#method(Type id, Type
id,...)
@see
package.Class
@see
package.Class#field
@see
package.Class#Constructor(Type, Type...)
@see
package.Class#Constructor(Type id, Type id)
@see package.Class#method(Type,
Type,...)
@see package.Class#method(Type
id, Type, id)
@see
package
@throws 异常
标识出方法可能抛出的异常
适用范围:方法
例: * @throws IOException If an input or output
exception occurred
@deprecated 解释
标识对象过期
适用范围:文件、类、方法
@link 链接地址
链接到一个目标,用法类似@see。但常放在注释的解释中形如{@link …}
例:
/**
* @deprecated As of JDK 1.1,
replaced by
* {@link
#setBounds(int,int,int,int)}
*/
没有这个属性的,你自己再写个类去继承file吧,添加一个creator属性,通过System.getProperty("user.name")来获得系统的用户名,来记录该文件的创建者,在写个get方法,以便以后取出这个属性值。public class Test1 {public static void main(String args[]) {
//测试两个线程
WriterThread writerThread=new WriterThread()
writerThread.start()
ReaderThread readerThread=new ReaderThread()
readerThread.start()
}
}
//字节输入的线程
class WriterThread extends Thread{
//加上synchronized实现同步,就能达到线程安全
public synchronized void run(){
File file=new File("c:/file.txt")
try {
FileWriter fileWriter = new FileWriter(file,true)//加上true就会在原有的基础上修改,而不会覆盖原来的
fileWriter.write("迦夜云书")
fileWriter.flush()
fileWriter.close()
} catch (IOException e) {
System.out.println("输入内容失败")
e.printStackTrace()
}
}
}
//字节输出的线程
class ReaderThread extends Thread{
public synchronized void run(){
File file=new File("c:/file.txt")
try {
FileReader fileReader = new FileReader(file)
char content[]=new char[1024]
int len=0
while((len=fileReader.read(content))!=-1){
System.out.println(new String(content, 0,len))
}
fileReader.close()
} catch (Exception e) {
System.out.println("读取内容失败")
e.printStackTrace()
}
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)