日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

java英文版怎么汉化_请问,java中,将下面的英文名字变为中文 该怎样输出?

發布時間:2024/7/23 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java英文版怎么汉化_请问,java中,将下面的英文名字变为中文 该怎样输出? 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

如題,下面是代碼——————————————————————————————importjava.io.*;publicclassRandomFileDemo{publicstaticvoidmain(String[]args)throwsException{Em...

如題,下面是代碼

——————————————————————————————

import java.io.*;

public class RandomFileDemo {

public static void main(String[] args) throws Exception {

Employee e1=new Employee("zhangsan",23);

Employee e2=new Employee("lisi",24);

Employee e3=new Employee("wangwu",25);

RandomAccessFile ra=new RandomAccessFile("d:\\baron\\java\\employee.txt","rw");

ra.write(e1.name.getBytes());

ra.writeInt(e1.age);

ra.write(e2.name.getBytes());

ra.writeInt(e2.age);

ra.write(e3.name.getBytes());

ra.writeInt(e3.age);

ra.close();

RandomAccessFile raf=new RandomAccessFile("d:\\baron\\java\\employee.txt","r");

raf.skipBytes(12);

String str="";

int len=8;

for(int i=0;i

str=str+(char)raf.readByte();

System.out.println("第二位員工信息");

System.out.println("name="+str+",age="+raf.readInt());

raf.seek(0);

str="";

for(int i=0;i

str=str+(char)raf.readByte();

System.out.println("第一位員工信息");

System.out.println("name="+str+",age="+raf.readInt());

raf.skipBytes(12);

str="";

for(int i=0;i

str=str+(char)raf.readByte();

System.out.println("第三位員工信息");

System.out.println("name="+str.trim()+",age="+raf.readInt());

raf.close();

}

}

class Employee {

String name;

int age;

final static int LEN=8;

public Employee(String name,int age) {

if(name.length()>LEN)

name=name.substring(0,8);

else {

while(name.length()

name=name+"\u0000";

}

this.name=name;

this.age=age;

}

}

————————————————————————————————

在不改變太多的情況下,我想將name中的 zhansan /lisi/wangwu 改為中文的 張三、李四、王五 應該怎么寫代碼呀?謝謝各位了

展開

總結

以上是生活随笔為你收集整理的java英文版怎么汉化_请问,java中,将下面的英文名字变为中文 该怎样输出?的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。