java中如何将字符串数组保存在数据库里

数组内容如下:
count=8
allGameNum=4
time=15
qtxt0=Hello, I'm David. I'm new here. Hello, I'm Helen. Let me show you our new building.How many classrooms are there in the building?There are thirty.Are there any reading rooms?
t0=C5-1
as0=1Yes, there are. There are two reading rooms.
bs0=Yes, there are thirty classrooms.
img0=C5-1
qtxt1=Hi, Ben. Weclome to my new house. Hi, Mary. Your garden is so beautiful. Thank you. Let's go and look at my new room? Wow, It's small but nice. Are there any flowers in your room?
t1=C5-2
as1=1Yes, there are. They're in the green vase.
bs1=Yes, there are. They're in the garden.
img1=C5-2
其中
qtxt,t0 ,as0,bs0,img0这些在数组中会有多个。不过在数组中名字会变,等于号后面的是要存入数据库中的数据,count,allGameNum,time在数组中是只有一个的。也需要取到后面的值存入数据库!请高手指点。谢谢!

既然是数组,有个简便的方法 你循环出来用逗号表达式来分隔例如下边:
String str[] ={"abc","cdf","aaa"};
StringBuffer buffer =new StingBuffer();
for(int i=0;i<str.length;i++){
buffer.append(str[i]+",");
}
用这个buffer.toString转换成字符串 存到数据库中,下次取这个数据的数据时候可以用String类的split方法来得到这个字符串数组
例如:String str ="abc,cbd,"aaa";
String str1[] =str.split(",")
温馨提示:答案为网友推荐,仅供参考
相似回答