|
Thank you all for the replies. I modified the code, and now it compiles ans run with no errors. But it doesn't output anything?!
Any clue?
import java.io.*;
import java.util.*;
public class mainStudnetProg
{
public static void main(String[] args)
{
StudentList studentList = new StudentList();
try
{
Scanner infile = new Scanner(new FileReader("C:\\studentInfo.txt"));
createStudentList(infile, studentList);
}
catch (FileNotFoundException fnfe)
{
System.out.println(fnfe.toString());
}
}
public static void createStudentList(Scanner infile, StudentList studentList)
{
String fName;
String lName;
int id;
Student newStudent;
while (infile.hasNextLine())
{
if (!infile.hasNextLine()){
break;
}
infile.hasNextLine();
fName = infile.nextLine();
if (!infile.hasNextLine()){
break;
}
infile.hasNextLine();
lName = infile.nextLine();
if (!infile.hasNextInt()){
break;
}
infile.hasNextInt();
id = infile.nextInt();
if (!infile.hasNextLine()){
break;
}
infile.hasNextLine();
infile.nextLine();
newStudent = new Student();
newStudent.setStudentInfo(fName, lName, id);
studentList.insertFirst(newStudent);
}
}
}
|
|
|
|
|
Babylon Lion wrote: it doesn't output anything?!
Any clue?
If there are no run-time exceptions, then the only way to get some output is by calling a method that outputs something. Can you point us to some of those, as I don't see any.
BTW: your hasNextLine() and nextLine() stuff is quite a mess IMO.
May I suggest you reconsider your current code, clean it up, and then do one of these two things:
1. add logging statements that show where you are; a few System.out.println("Now going to ..."); could do wonders.
2. learn to use your debugger, with breakpoints and single-stepping, so you can slowly execute your code and look at the statements being executed one at a time.
Also, if you're new to programming, maybe it would be wise:
1. to study an introductory book of your choice, from the start;
2. to start out with simpler stuff, probably from said book.
Good luck.
|
|
|
|
|
When i run openoffice in applet i got this exception, This not getting frequently, sometimes oo writer loads in applet. But in some situations i got this exception. Please help
My os is windows xp
oo version is 3.2
==============
com.sun.star.uno.RuntimeException: Could not create system bitmap!
at com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException(Job.java:177)
at com.sun.star.lib.uno.environments.remote.Job.execute(Job.java:143)
at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:335)
at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:304)
at com.sun.star.lib.uno.environments.remote.JavaThreadPool.enter(JavaThreadPool.java:91)
at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:639)
at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.request(ProxyFactory.java:151)
at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.invoke(ProxyFactory.java:133)
at $Proxy9.initialize(Unknown Source)
at com.sun.star.comp.beans.Frame.initialize(Frame.java:65)
at com.sun.star.comp.beans.abbeans.loadFromURL(abbeans.java:586)
at com.sun.star.comp.beans.OOoBeanViewer$11.run(OOoBeanViewer.java:357)
at com.sun.star.comp.beans.OOoBeanViewer$11.run(OOoBeanViewer.java:341)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.star.comp.beans.OOoBeanViewer.createNewTranscript(OOoBeanViewer.java:341)
at com.sun.star.comp.beans.OOoBeanViewer.access$1300(OOoBeanViewer.java:93)
at com.sun.star.comp.beans.OOoBeanViewer$16.run(OOoBeanViewer.java:1279)
at com.sun.star.comp.beans.OOoBeanViewer$16.run(OOoBeanViewer.java:1264)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.star.comp.beans.OOoBeanViewer.openDocument(OOoBeanViewer.java:1264)
at com.sun.star.comp.beans.OOoBeanViewer$12.run(OOoBeanViewer.java:509)
at com.sun.star.comp.beans.OOoBeanViewer$12.run(OOoBeanViewer.java:479)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.star.comp.beans.OOoBeanViewer.loadFile(OOoBeanViewer.java:479)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.plugin.javascript.JSInvoke.invoke(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.plugin.javascript.JSClassLoader.invoke(Unknown Source)
at sun.plugin2.liveconnect.JavaClass$MethodInfo.invoke(Unknown Source)
at sun.plugin2.liveconnect.JavaClass$MemberBundle.invoke(Unknown Source)
at sun.plugin2.liveconnect.JavaClass.invoke0(Unknown Source)
at sun.plugin2.liveconnect.JavaClass.invoke(Unknown Source)
at sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo$DefaultInvocationDelegate.invoke(Unknown Source)
at sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo.doObjectOp(Unknown Source)
at sun.plugin2.main.client.LiveConnectSupport$PerAppletInfo$LiveConnectWorker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
|
|
|
|
|
You are running Open Office in an applet frame - is that right?
Or are you creating an Applet in a Open Office document?
no matter which way you're doing it - seems to me like a Open Office Issue: Support @ Open Office.org
regards
Torsten
I never finish anyth...
|
|
|
|
|
Yes, Am using OOoviewer from OO3.2 sdk. I have already posted this issue in Support @ Open Office.org . I didnt got any support from there. Please help me
|
|
|
|
|
Hey!
I changed work place and my new company uses the Window Builder / SWT Designer. I'm used to make my GUIs code based, leading to a clean and smart code. The Window Builder just pushes the code in, not formatted or using basic OOP stuff like capsulation or any method based variables (every component is set as a class member).
so how do you doing your JAVA GUIs?
regards,
Torsten
I never finish anyth...
|
|
|
|
|
Hand-code or use a visual designer? It's one of these religious things for some people, like where do you put your squiggly brackets, same line or next line?
In the past I have used layout managers like JGoodies Forms or MiG. Both excellent, both code based (although you can get designers for Forms). The problem I have found with using code is not in the initial build, it's in the maintenance, when a customer says, "Actually, I'd like this new field added and all this other stuff moved round". That can be tricky to visualise when you are looking at a screen full of code trying to figure out in your head what you need to change to get the new look the customer has asked for. Some people find that easy to do (visualise the look of the screen by reading code), I don't. JGoodies Forms in particular can be hard to decipher to work out what the screen will look like.
So for that, a visual designer is really helpful. You can see immediately what the screen will look like, just drag this field over here, move that down a bit, and drop my new component in there... I quite like Matisse (the NetBeans designer), it's easy to use and gives good results. The code is generated for me, code-folding hides it, I never look at it. Why would I? I have not yet seen any sort of performance problem or bug with the Matisse-generated code.
On the other hand, sometimes you want to get a bit more clever and start doing things that Matisse can't do, and in that case you need to drop back to doing it in code. And you can't really start with Matisse's code and add in the features you want, it's better then to start right from scratch with hand-crafting the layout.
At the end of the day, I'm agnostic. Sometimes code is better, sometimes a designer tool is better.
|
|
|
|
|
It looks like you are using SWT. You might also have a loko at JFace, it is an excellent library on top of SWT providing classes for dialogs, viewers (an easier way to populate widgets like trees, tables, ...), ...
Most of the time, I design the UI through code (I use layout managers a lot, which helps building a nice UI). I also used Jigloo, which is a tool to design dialogs in SWT.
On the other hand, I use the RCP framework from Eclipse a lot. If you have to design an application which has to have support for views and documents (like Eclipse for instance), I strongly suggest you take a look at RCP. If you are interested, you should learn it from a book, because it is a rather complex framework but very powerful if you need to do this kind of development.
|
|
|
|
|
|
Yes usually designing UI takes quite some time only for the UI part (not taking into account any functionalities). If you have to redesign some part of your UI, I think it is more efficient by code, not using any tool (well, unless you want to start from scratch again).
Anyway, have a look at Jigloo, it is quite a nice designer and very well integrated in Eclipse. The code generated is readable and well formatted too (maybe a bit verbose but it's ok).
|
|
|
|
|
OK, I'll check that one out. Thanks.
regards,
Torsten
I never finish anyth...
|
|
|
|
|
Horses for courses.
Quick jobs are done using netbeans's inbuilt tools. More often than not, these are then /heavily refactored/ to my own coding standards.
For 78% of dialogs, I use an XML definition to generate the layout on the fly.
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
|
|
|
|
|
I've only recently started making GUI's for Java applications, and I find it easier with Netbeans' drag and drop Swing components
See if you can crack this: fb29a481781fe9b3fb8de57cda45fbef
The unofficial awesome history of Code Project's Bob!
"People demand freedom of speech to make up for the freedom of thought which they avoid."
|
|
|
|
|
yaah netbeans is good for modifications and all that but swing hack is good you can do amazing things
i thought you were going to help...............
|
|
|
|
|
hmm, I'm the eclipse sort of user.
I'm using the WindowBuilder right now in a new small project.
If one takes care of the code, it works as mentioned. But you need to take care right from the beginning.
regards,
Torsten
I never finish anyth...
|
|
|
|
|
Hi friends ,
I was trying to compile a simple Socket Program where i encountered the following error...I am not able to fix it ..Can anyone help me..?
Error is : No IO for host dkc678-01
Thanks.
Please find my code below:
import java.net.*;
import java.io.*;
public class EchoClient
{
public static void main(String[] args) throws IOException
{
Socket echosocket = null;
PrintWriter out =null;
BufferedReader in=null;
try
{
echosocket = new Socket("dkc678-01",7);
out=new PrintWriter(echosocket.getOutputStream(),true);
in=new BufferedReader(new InputStreamReader(echosocket.getInputStream()));
}
catch(UnknownHostException e)
{
System.err.print("Unable to find the host dkc678-01");
System.exit(1);
}
catch(IOException e)
{
System.err.print("No IO for host dkc678-01");
System.exit(1);
}
BufferedReader stdIn=new BufferedReader(new InputStreamReader(System.in));
String userInput;
while((userInput =stdIn.readLine())!= null )
{
out.println(userInput); System.out.println("echo :" + in.readLine }
out.close();
in.close();
stdIn.close();
echosocket.close();
}
}
|
|
|
|
|
|
hi Torsten,
i was trying the same program(shown in your link)...but i couldn't find a solution for my error.
I tried with a different host and port ,then the connection was opened..
But now my problem is every time the BufferedReader connected to the socket contains some already existing lines of text which is printed ..where as in my program i am supposed to get an echo of whatever the user had typed...Hope the problem is clear to you.
|
|
|
|
|
|
its not working Torsten...when i am reseting it ,i am getting an Exception as the following..
Exception in thread "main" java.io.IOException: Stream not marked
Pelase help me to get a solution...
Thanks..
|
|
|
|
|
Look at your code: you catch an exception and print a totally useless and incomprehensible message. Try printing something meaningful and useful from the information provided by the exception.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
can you read the documentation?
InetSocketAddress address = new InetSocketAddress(hostName, port);
socket.connect(address);
out = new DataOutputStream(socket.getOutputStream());
out.writeBytes(msg);
|
|
|
|
|
how do i modify or write inside a shock wave file..pls help
|
|
|
|
|
|
hey i m wrking on .swf file and i want to onsert sum text or image on specific part.is it possible?hey thanks for the reply.
|
|
|
|