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

📄 phones.java

📁 Java 图形界面入门实例
💻 JAVA
字号:
import java.io.*;

public class Phones
{  static FileOutputStream fos;
   public static final int lineLength=81;
   public static void main(String atgs[])
   {   byte[] phone=new byte[lineLength];
       byte[] name=new byte[lineLength];
	   int i;
	   try
	   { 
		   fos=new FileOutputStream("phone.txt");
	   }
	   catch(FileNotFoundException e)
	   {    }
	   while(true)
	   {   System.err.println("输入一个名字:(输入done退出)");
	       readLine(name);
		   if("done".equalsIgnoreCase(new String(name,0,0,4)))
		   {  break;}
		   System.err.print("输入这个电话号码:");
           readLine(phone);
		   for(i=0;phone[i]!=0;i++)
		   {  fos.write(phone[i]);
		   }
		   fos.write(',');
           for(i=0;phone[i]!=0;i++)
		   { fos.write(name[i]);
		   }
		   fos.write('\n');
	   }
	   fos.close();
   }
   
   private static void readLine(byte line[])throws IOException
   {   int i=0,b=0;
       while((i<lineLength-1)&&((b=System.in.read())!='\n'))
	   {  line[i++]=(byte) b;
	   }
	   line[i]=(byte) 0;
   }
}

⌨️ 快捷键说明

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