java增加版本号_Java如何⽣成版本号?⽐如000100020002展开全部
⾸先还是不太明⽩你说的这636f70793231313335323631343130323136353331333431373261个“⽣成版本号”是什么意思,如果只是⽣成⼀个⾃增序列的话
1、如果有oracle数据库的话可以利⽤它的序列⽣成。
2、没有oracle,⽤redis也⾏。
3、没有数据库,那就写个⽂件来存取吧:
public class Test2 {
public static void main(String[] args) throws IOException {
System.out.println(getSequence("d:\\test\\"));
tSequence("d:\\test\\", "");
System.out.println(getSequence("d:\\test\\"));
蛋白粉用量}
//读取序列
英语一年级public static String getSequence(String quenceFile) throws IOException {
FileInputStream fileInputStream = null;
InputStreamReader inputStreamReader = null;
BufferedReader bufferedReader = null;
try {
File file = new File(quenceFile);
fileInputStream = new FileInputStream(file);
inputStreamReader = new InputStreamReader(fileInputStream);
bufferedReader = new BufferedReader(inputStreamReader);
// 按⾏读取字符串
String str;
if ((str = adLine()) != null) {
卖房个人所得税return str;
}
return null;
} catch (Exception e) {
e.printStackTrace();
return null;
} finally {
if (bufferedReader != null) {
bufferedReader.clo();
骂人专用图
}
自制戚风蛋糕
if (inputStreamReader != null) {
inputStreamReader.clo();
}
if (fileInputStream != null) {
fileInputStream.clo();
}
}
}
//设置序列,如果传⼊的序列号为空,则在原序列的基础上+1
public static void tSequence(String quenceFile, String quence) throws IOException { if (quence == null || quence.isEmpty()) {
String oriSequence = getSequence(quenceFile);
quence = String.format("%04d", Integer.valueOf(oriSequence) + 1);
}
FileOutputStream fileOutputStream = null;
OutputStreamWriter outputStreamWriter = null;
BufferedWriter bufferedWriter = null;
try {
File file = new File(quenceFile);
红薯的功效与作用fileOutputStream = new FileOutputStream(file);
outputStreamWriter = new OutputStreamWriter(fileOutputStream);
bufferedWriter = new BufferedWriter(outputStreamWriter);
bufferedWriter.write(quence);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (bufferedWriter != null) {
bufferedWriter.clo();
}
if (outputStreamWriter != null) {五述报告
outputStreamWriter.clo();
}
if (fileOutputStream != null) { fileOutputStream.clo();
}
}
}
}
代码⼜挤在⼀起了:
读序列:
写序列:
运⾏结果:
先⽣成好这个⽂件:
冲!:
辐射防护