i don't know if anyone else has started working on this... i was just wondering if we are supposed to keep the file the same with the ByteBuffer and continue working with each character one at a time the way the current program does. Otherwise is there a way to look at one word at a time?
You can do it however you want as long as the result works. That said, the ByteBuffer in the sample program already works and is the easiest way to do it. But feel free to explore other options if you want.
Is anyone else using JGrasp? I can't remember what Dr. Garrett said about using JGrasp. Wasn't there something extra or a little bit different we have to do compared to using a different program?
In JGrasp you have to check the "Run Arguments" option under Build on the top menu bar. A text box will appear at the top of the code window, so you just have to type in the names of the input and output files before running the program.
1. Highlight your class on the left 2. From the menu, select the run icon, get the dropdown menu, and choose RUN 3. The run dialog box should appear. In that dialog box there is a tab that says "arguments" 4. Click on the arguments tab and place your arguments in the "program arguments" box 5. Those arguments will remain in place until you remove them or change them. Anytime your run the program, the arguments will be used.
Would it be safe to assume that the test files used will be in the same format as the sample (single space between each first and last name, carriage return after each record) ?
Also does "mixed character" mean the way that the characters are already in the input file?
I noticed that in the Project 2 requirements it says "mixed characters (first letter upper case, remainder lower case)", but some people have some odd last names with capital letters in the MIDDLE of their last names that could potentially throw a wrench in the output, depending on how its processed. To solve this, the code could just throw the byte exactly how it is into the buffer, which would work unless the input file was say... entirely in lower case and the desired output was to have the first letter of the last names capitalized.
But the output of trying to format an unformatted input of entirely lower case (ex. output: Warden-michl) could be potentially as incorrect as unformatted input file remaining unformatted (ex. output: warden-michl). I see no good solution unless the input file is already formatted into the correct "mixed characters." I hope that is what is expected?
I was wondering the same thing about the mixed case. For my output, mixed case means exactly what the assignment said: first letter uppercase, the rest lowercase. So when the switch -X is used, the output is Warden-michl, etc.
I'm having some issues getting things rolling here. I guess the main problem I'm having is creating a string for each record so I can parse it into last and first names.
Is it possible to parse the file by using FileChannels and ByteBuffers? I'm stumped.
For this assignment, "mixed case" means capitalizing the first letter of each name. Obviously, that technique wouldn't always work in real life, but that's the expectation for this assignment.
when using the char c, you can test to see if c == ' ' (space) or c == ',' or c == '\n' (new line) to determine where the ends of the last and first names are.
I'm having trouble with the argument check, as long as anything is typed in as the third argument it'll do the check and run with the -X or a non -X arg, but if there isn't a 3rd at all I get a ArrayIndexOutOfBoundsException and not sure what to do about it.
I know it's a little late to post this, but figured I wouldn't be the only one doing this last minute.
sounds like you are trying to access args(2) when nothing is their, causing a exception. To fix this you will need something to make sure you have a 3rd argument. somthing like if (args.length >= 3) then do the check if it is a -X or not
im having problems getting the names to appear properly in the file. the way i tried doing it was putting the characters that i read in from the inputfile into a string until i reached a comma then changing the whole string to uppercase. when i tried writing the sstring to a file i got errors so i put it into a for loop and tried ouputting the characters one a time into the output file. but im still having problems
for ( int count = 0; count < name.length(); count++ ) { letter = name.charAt(count); bb.put( i, (byte) letter ); fcout.write( bb ); here is the code i have for outputting to the file i, bb fcout are all the same as in the original. does anyone see anything wrong that they assist me with? any help is appreciated kevin
I had issues with mine when I tried to check for the comma to change case, my problems went away when I started checking for the blank space. Then I simply used a trigger to control case. if trigger == 0 Ucase, else Lcase.. controlled it with if statements. had two sets of if's controlling wether it had the -X or not
kevin, quick look at that seems to me like the fcout.write(bb); would cause problems if it was in the loop. Not 100% sure but i would try removing it from the loop, and having it write the file after the loop is done. Something like bb.rewind; fcout.write(bb); should write everything in the buffer after the loop is done. This is just my 2am thoughts and a quick look at what you posted... may not help at all