编写一个Java应用程序,实现将一个由英文字母、数字及其他符号构成的文件(a.txt)通过加密之后写入另外
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/10/04 13:10:38
编写一个Java应用程序,实现将一个由英文字母、数字及其他符号构成的文件(a.txt)通过加密之后写入另外
个文件(b.txt)中.
加密算法为:如果是英文字母,则采用字母+1% 26的方式转换;如果是数字则采用(1234567890)的倒数的方式转换,除此之外的符号原样输出.
例如:源文件内的内容为ah0123,:Mz,则目标文件内容为bi1098,:Na
个文件(b.txt)中.
加密算法为:如果是英文字母,则采用字母+1% 26的方式转换;如果是数字则采用(1234567890)的倒数的方式转换,除此之外的符号原样输出.
例如:源文件内的内容为ah0123,:Mz,则目标文件内容为bi1098,:Na
做回好人,回答你吧.直接看代码:
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class jiami {
public static void main(String[] args) {
String source=null,target=null;
try {
FileInputStream fileread = new FileInputStream(new File("D:/a.txt"));//路径自己改
int length = fileread.available();
byte[] buffer = new byte[length];
fileread.read(buffer);
source = new String(buffer);//读取
fileread.close();
} catch (Exception e) {
e.printStackTrace();
}
if(source==null)
System.out.println("a.txt为空");
else{
System.out.println(source);
target=zhuanhuan(source);
System.out.println(target);
try {
FileOutputStream out = new FileOutputStream(new File("D:/b.txt"));
out.write(target.getBytes());//写入
out.close();
} catch (FileNotFoundException e1) {
e1.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static String zhuanhuan(String s){
char []array = s.toCharArray();
for(int i=0;i=65&&j=97&&j
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class jiami {
public static void main(String[] args) {
String source=null,target=null;
try {
FileInputStream fileread = new FileInputStream(new File("D:/a.txt"));//路径自己改
int length = fileread.available();
byte[] buffer = new byte[length];
fileread.read(buffer);
source = new String(buffer);//读取
fileread.close();
} catch (Exception e) {
e.printStackTrace();
}
if(source==null)
System.out.println("a.txt为空");
else{
System.out.println(source);
target=zhuanhuan(source);
System.out.println(target);
try {
FileOutputStream out = new FileOutputStream(new File("D:/b.txt"));
out.write(target.getBytes());//写入
out.close();
} catch (FileNotFoundException e1) {
e1.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static String zhuanhuan(String s){
char []array = s.toCharArray();
for(int i=0;i=65&&j=97&&j
编写一个Java应用程序,实现将一个由英文字母、数字及其他符号构成的文件(a.txt)通过加密之后写入另外
编写Java应用程序,求任意一个三位数的数字之和
编写一个java application程序,运用加密操作将字母变成倒序字母,如A变成Z,B变成Y?
编写一个JAVA应用程序,计算两个正整数的最大公约数和最小公倍数,要求从键盘输入两个数
编写一个Java应用程序,求这12和18的最小公倍数和最大公约数.
编写一个java应用程序,要求输入两个整数,并显示这两个数的和、差.
用c语言编程:输入一个字符串,统计其中英文字母,数字符号及其他字符的个数
文件保密传递常常是按一定规则将其加密,收件人再按约定的规则将其解密,某电文按下面规则加密:将一个英文字母变成英文字母表中
用JAVA编写求解几何图形的应用程序?
用Java编写20. 编写程序,21. 当给出一个英文字符串,22. 能够统计其中大写字母、小写字母、数字、空格及其他字
1、编写一个程序,将两个Java程序文件显示到屏幕上.
编写一个Java应用程序,计算1-1/2+1/3-1/4+…的前100项之和.