佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1080|回复: 2

拜托会的帮帮忙....

[复制链接]
发表于 16-10-2010 01:46 PM | 显示全部楼层 |阅读模式
我用了Iterator但是在notepad却不能跳去下一行

出来是这样:

[Ben, Emelia, Linda, Orlando, Romeo, Ruth, Watson]

我要的是这样:
Ben
Emelia
linda
orlando
romeo
ruth
watson



import java.util.*;
import java.io.*;

public class StudentAcc
{

public static void main(String [] args){

TreeSet<String>currAccs = new TreeSet<String>();

TreeSet<String>oldAccs = new TreeSet<String>();

TreeSet<String>gradAccs = new TreeSet<String>();

TreeSet<String>newAccs = new TreeSet<String>();



try

{

readAccounts("currAccounts.txt",currAccs);

readAccounts("oldAccounts.txt",oldAccs);



gradAccs.addAll(oldAccs);

gradAccs.removeAll(currAccs);

newAccs.addAll(currAccs);

newAccs.removeAll(oldAccs);


}

catch(IOException ioe){

System.out.println("Cannot open file");

System.exit(1);

}

FileOutputStream out1;

PrintStream p1;

FileOutputStream out2;

PrintStream p2;

try

{

out1 = new FileOutputStream("gradAccounts.txt");

out2 = new FileOutputStream("newAccounts.txt");



p1 = new PrintStream(out1);

p2 = new PrintStream(out2);

p1.println(gradAccs);

p2.println(newAccs);

p1.close();

p2.close();

}

catch (Exception A)

{

System.out.println("Error writing to file");

}



System.out.println("Graduated Students");

System.out.println("-------------------");

Iterator iter = gradAccs.iterator();

while (iter.hasNext())

{


System.out.println(iter.next()+" ");

}



System.out.println();

System.out.println("New Students");

System.out.println("-------------------");

Iterator iter2 = newAccs.iterator();

while (iter2.hasNext())

{


System.out.println(iter2.next()+" ");

}

}
谁可以帮帮忙??????????????非常紧急
回复

使用道具 举报


ADVERTISEMENT

发表于 16-10-2010 11:31 PM | 显示全部楼层
try to use this :

str = "\n"
for new line
回复

使用道具 举报

发表于 17-10-2010 10:00 PM | 显示全部楼层
回复 2# mrhaha80

没用的。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 18-11-2025 08:09 AM , Processed in 0.346238 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表