當前位置:編程學習大全網 - 網站源碼 - 加密文件網站源代碼

加密文件網站源代碼

導入Java . io . *;

公共類機密示例{

公共靜態void main(String[] args) {

File File one = new File(" d:/hello . txt "),File two = new File(" d:/hello . secret ");

char b[]= new char[100];

嘗試

{

FileReader in = new FileReader(file one);

FileWriter out = new FileWriter(file two);

int n =-1;

while((n=in.read(b))!=-1)

{

for(int I = 0;我& ltn;i++)

{

b[i]=(char)(b[i]^'a');

}

out . write(b);

//寫文件

}

out . close();//關閉

in = new file reader(file two);

System.out.println("加密文件內容:");

while((n=in.read(b))!=-1)

{

String str =新字符串(b,0,n);

system . out . println(str);

}

in = new file reader(file two);

System.out.println("解密文件內容:");

while((n=in.read(b))!=-1)

{

for(int I = 0;我& ltn;i++)

{

b[i]=(char)(b[i]^'a');

}

System.out.printf(new String(b,0,n));

}

in . close();//在中關閉

}

捕捉(IOException e)

{

system . out . println(e);

}

}

}

  • 上一篇:微信跑腿公眾號怎麽搭建
  • 下一篇:電腦上帶的玩紙牌遊戲怎麽在蘋果手機上玩
  • copyright 2024編程學習大全網