User Profile
Collapse
-
Yeah good idea. Thanks a lot. :-) -
Binary file problem
I am writing to a binary file. My poblem is that i want that the next time it write to the file it will write on a new line. What can i do? Thanks a lot.
This is the piece of code that writes to the file:
Code:File aFile = new File( "players.dat" ); // create an output stream to the file FileOutputStream aFileOutStream = new FileOutputStream
-
Ok i took your advice, but still it keeps displaying "Invalid" even when entering the correct word.
Code:do { type = JOptionPane.showInputDialog(null, "Invalid entry. Try again." ); } while(!type.equals("Earthquakes") || !type.equals("Place") || !type.equals("Animals"));
Leave a comment:
-
Do while loop problem
I have a problem with do while loop. I am displaying a dialogue box where a person should enter the type of quiz he had performed. The problem is that the user should enter only the following 3 words, either "Earthquake s" or "Place" or "Animals". If the user enters any other word, he/she should be displayed wwith another message saying "Invalid". This should keep repeatinf (i.e. displaying invalid) until the... -
problem with alligning
Is there any method in how i can allign text in java being displayed in a textArea?
Thanks a lot. -
Problem in sort
I am doing a game, where a user enters his name after playing the game. This name together with the percentage score are being written (stored) in a textfile called players.txt I am however trying to sort the percentage score with the highest placed on top. I have written this piece of code, but i'm stuck since altough the names and scores are being written on the file, they are not being sorted. Pls can someone help me sort them? Thanks a lot.... -
sorting problem
Im trying to sort a set of names, stored in a textfile in acscending order (this textfile contains also the marks of each student). I did this piece of code, but altough its compiling its not sorting them. Can someone pls help me with this problem. Thanks a lot.
Code:import java.awt.BorderLayout; import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import javax.swing.JDialog;
-
Ok i understood that(why its displaying players.dat. But how can i append the file, so it would display its contents. Because i can't figure out how to call the file to be displayed in the textArea. Thanks a lot for your help.Leave a comment:
-
Ok thanks a lot. I tried doing this, but instead of displaying the contents of the binary file (i.e the scores) it just displays "players.da t". What am i doing wrong? Thanks a lot. I really appreciate all your help.
Code:import java.awt.BorderLayout; import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import javax.swing.JDialog; import javax.swing.JTextArea;
Leave a comment:
-
No, its just i am doing like a quiz. And my tutor told me that instead of saving the scores in a textfile i should store them in a binary file since binary files are more secure. And i want to display these scores into a JTextArea. I'm still a beginner and so i'm not just of an expert in java. Hope that this would give a more clearer idea of what i'm doing. Thanks a lot, and sorry for the trouble.Leave a comment:
-
The problem is that i don't know how to call a binary file, to be displayed in a textArea. I know how to display a textfile in a textArea, but since binary files contain unreadable data, i can't display the contents of a binary file like i display a textfile. When i tried to display the contents of the binary file like i display them when they are stored in a textfile, it displays jumbled up characters (the way binary file stores them). I want...Leave a comment:
-
When you open a binary file like in a text editor, you can't read data, because its not readable. It contains jumbled up text and characters. Its not like a textfile where you can edit or read the data contained.Leave a comment:
-
No, i want to display the data not the one's and zero. Thats why i am having problems. Because since binary files are not in a human readable mode, i want that when they are displayed on the textArea they are human readable (not with the zeros). Is there a way how i could display them in this way?
Thanks.Leave a comment:
-
TextArea
Is there a way how i can display the contents of a binary file in a textArea? -
I have read it now. Thanks a lot. But the problem still remanains. Since i have to pass not a set of numbers to the array, but every score that the user scores, which is stored in the textfile. What do i have to pass to the array so it would read all the scores that are stored in the file. Thanks again.Leave a comment:
-
My problem is that the program isn't sorting the high scores. In my program according to my tutor i have to use a bubble sort. The program is cpompiling and it is displaying the score. The problem is that its not sorting them. I think the problem is because i'm only passing one number to the array everytime a user does his turn in the game. The scores one scored are written directly into a text file. Therefore my problem is how to sort these numbers...Leave a comment:
-
Yes its an assignment. I have to use a bubble sort. I tried doing it but its not sorting the scores.Leave a comment:
-
sorting problem
I've got a problem in sorting. I have to use a bubble sort to sort the scores with those who bring the highest percent at the top. The scores of each user i saved in a text file. This is how i tried to do the sorting but its not working. Can someone pls help me out. Thanks a lot.
[CODE=java]for(int j = 0; j < questions.lengt h; j++) {
int randomIndex = B[j];... -
-
textArea problem
I am displaying the contents of a textfile in a textArea. I want that when i edit this text in the textArea it is automatically saved in the textfile. I have wriitten this code, but the problem is that when i edit the text in the text Area it isn't saving it on the textfile. What do i have wrong? Thanks a lot.
Code:import java.awt.BorderLayout; import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream;
No activity results to display
Show More
Leave a comment: