首页 > 其他 > 详细

2020.02.29 天衣无缝代码

时间:2020-03-01 01:01:12      阅读:93      评论:0      收藏:0      [点我收藏+]
package com.guoyun.bean;

import java.lang.annotation.Target;

/**
* ClassName:
* Function: ADD FUNCTION
* Reason: ADD REASON
*
* @author
* @Date
* @since Ver 1.1
*/
public class SecretCode {
private int[] content=new int[20];
private int pswkey;

public SecretCode(int[] content, int pswkey) {
this.content = content;
this.pswkey = pswkey;
}
public void show(){
System.out.println("解析后的密码为:");
for (int i = 0; i <content.length ; i++) {
if(content[i]!=0){
System.out.println((char) (content[i] - pswkey));

}
System.out.println();
}

}
public int[] responed(){
int[] temp=new int[20];
String content="ok,copythat!";
char[] chars=content.toCharArray();
for (int i = 0; i < chars.length; i++) {
temp[i]=chars[i]+pswkey ;
}
return temp;
}
}
********************************************************************
package com.guoyun.utils;

import com.guoyun.bean.SecretCode;

import java.io.*;

/**
* ClassName:
* Function: ADD FUNCTION
* Reason: ADD REASON
*
* @author
* @Date
* @since Ver 1.1
*/
public class FileUtils {
SecretCode secretCode;
public void readCode(){
BufferedReader reader=null;
String temp="";
try {
reader=new BufferedReader(new FileReader("E:/JAVA/新建文件夹/code.txt"));
while ((temp=reader.readLine())!=null){

String[] s = temp.split(" ");
int[] arr=new int[20];
for (int i = 0; i <s.length ; i++) {
arr[i]=Integer.parseInt(s[i]);


}
secretCode=new SecretCode(arr,8);
secretCode.show();
}
} catch (Exception e) {
System.out.println(e.getStackTrace());
}finally {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}

}

}
public void writeCode(){
BufferedWriter writer=null;
try {
writer=new BufferedWriter(new FileWriter("E:/JAVA/新建文件夹/code.txt",true));
int[] arr=secretCode.responed();
writer.newLine();
for (int i = 0; i <arr.length ; i++) {
writer.write(arr[i]+" ");
}
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
*****************************************************************************
package com.guoyun.view;

import com.guoyun.utils.FileUtils;

/**
* ClassName:
* Function: ADD FUNCTION
* Reason: ADD REASON
*
* @author
* @Date
* @since Ver 1.1
*/
public class MainView {
public static void main(String[] args) {
FileUtils fileUtils=new FileUtils();
fileUtils.readCode();
fileUtils.writeCode();
}
}


2020.02.29 天衣无缝代码

原文:https://www.cnblogs.com/aojie/p/12386865.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!