⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 example10_6.java

📁 不错的教程 适合中高级人员的使用
💻 JAVA
字号:
import java.io.*;
class Example10_6
{  public static void main(String args[])
   {  char a[]="今晚10点发起总攻".toCharArray();   
      int n=0,m=0;
      try{  File f=new File("secret.txt");
            for(int i=0;i<a.length;i++)
               {  a[i]=(char)(a[i]^'R');
               }
            FileWriter out=new FileWriter(f);
            out.write(a,0,a.length);
            out.close();
            FileReader in=new FileReader(f);
            int length=(int)f.length();
            char tom[]=new char[length];
            while((n=in.read(tom,0,length))!=-1) 
                {  String s=new String (tom,0,n);
                   m=n;   
                   System.out.println("密文:"+s);
                }
            in.close();
            for(int i=0;i<m;i++)
               {  tom[i]=(char)(tom[i]^'R');
               }
            String 明文=new String(tom,0,m);
            System.out.println("明文:"+明文);
         }
      catch(IOException e)
         {  System.out.println("File read Error");
         }
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -