大家好,需要帮助! [英] hi all, help needed!

查看:81
本文介绍了大家好,需要帮助!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这段代码:

Hi, I have this code :

展开 | 选择 | Wrap | 行号

推荐答案


我有这个代码:


公共类测试2

{



public static void readAccounts()

{

reader1 r = new reader1();

r.readIt() ;

}


public static void main(String args [])


抛出java.io.IOException ,java.io.FileNotFoundException

{

String st r =""

;

String [] lines = str.split(" \\&");

for(int i = 0;我< lines.length; i ++)

{


}

}

}


好​​的readAccounts方法链接到另一个类:


{

void readIt()

{

printFile(" account.txt");


}


void printFile(String fileName)

{

String [] lines = LineIO.readAllLines(fileName);

for(String l:lines)

{

System.out.println(l);

}

}


}


读取文本文件。我的问题是如何让我的第一段代码拆分文本文件中的字符串?我愚蠢地卡住了这个,所以任何帮助都会受到欢迎!


谢谢上帝喜欢的人!
Hi, I have this code :

public class test2
{


public static void readAccounts()
{
reader1 r = new reader1();
r.readIt();
}

public static void main(String args[])

throws java.io.IOException, java.io.FileNotFoundException
{
String str = ""
;
String[] lines = str.split ("\\&");
for (int i=0; i < lines.length; i++)
{

}
}
}

Ok the readAccounts method links to another class:

{
void readIt()
{
printFile("account.txt");


}

void printFile(String fileName)
{
String[] lines = LineIO.readAllLines(fileName);
for (String l : lines)
{
System.out.println(l);
}
}

}

which reads a text file. My question is how do I get my 1st piece of code to split the strings in the text file? Im stupidly stuck pon this so any help would be welcome!

Thankyou god like people!



你想如何拆分字符串?例如,在空格上拆分字符串使用str.split("");

How do you want to split the strings? eg to split a string on space use str.split(" ");



如何拆分字符串?例如,在空间上拆分字符串使用str.split("");
How do you want to split the strings? eg to split a string on space use str.split(" ");



抱歉,应该已经指定。数据由&符号(&)分隔,一些字符串包含我需要以后才能使用的数字。


谢谢


sorry, should have specified. The data is seperated by ampersans (&), some of the strings contain numbers which I need toi be able to work with later.

Thanks



对不起,应该已经指定了。数据由&符号(&)分隔,一些字符串包含我需要以后才能使用的数字。


谢谢
sorry, should have specified. The data is seperated by ampersans (&), some of the strings contain numbers which I need toi be able to work with later.

Thanks



然后使用str.split("&");

Then use str.split("&");


这篇关于大家好,需要帮助!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆