当前位置: 技术问答>java相关
关于读取文本中中文内容的问题
来源: 互联网 发布时间:2015-01-27
本文导语: split.java内容如下: import java.util.*; import java.io.*; public class split { public static void main(String args[]) { try{ RandomAccessFile tfile=new RandomAccessFile("list.txt","rw"); ...
split.java内容如下:
import java.util.*;
import java.io.*;
public class split
{
public static void main(String args[])
{
try{
RandomAccessFile tfile=new RandomAccessFile("list.txt","rw");
String str=new String();
int k=0;
while((str=tfile.readLine())!=null)
{
//System.out.println(str);
if(k%2==0)
{
System.out.println(k);
String text=new String(str.getBytes("8859_1"),"gb2312");
StringTokenizer st = new StringTokenizer(text,",");
//StringTokenizer st = new StringTokenizer(str,",");
int i=0;
int count=st.countTokens();
String[] strs=new String[count];
while(st.hasMoreTokens())
{
//String text=st.nextToken().trim();
//String text=new String(st.nextToken().trim().getBytes("8859_1"), "GB2312");
strs[i]=st.nextToken().trim();
i++;
}
for(int j=0;j
import java.util.*;
import java.io.*;
public class split
{
public static void main(String args[])
{
try{
RandomAccessFile tfile=new RandomAccessFile("list.txt","rw");
String str=new String();
int k=0;
while((str=tfile.readLine())!=null)
{
//System.out.println(str);
if(k%2==0)
{
System.out.println(k);
String text=new String(str.getBytes("8859_1"),"gb2312");
StringTokenizer st = new StringTokenizer(text,",");
//StringTokenizer st = new StringTokenizer(str,",");
int i=0;
int count=st.countTokens();
String[] strs=new String[count];
while(st.hasMoreTokens())
{
//String text=st.nextToken().trim();
//String text=new String(st.nextToken().trim().getBytes("8859_1"), "GB2312");
strs[i]=st.nextToken().trim();
i++;
}
for(int j=0;j