Results 1 to 9 of 9
Thread: Condition ignored.
- 12-05-2011, 11:18 PM #1
Condition ignored.
The "if" condition at line 22 is ignored.
It is suppose to append the read(from the stream) character to codeToken three times(the "if" condition at line 22 make sure that happen), but instead, its ignored all the time.
The output is like this:
------------
h
------------
h
------------
e
------------
C
------------
------------
------------
------------
hhe
------------
------------
------------
Cd4Java Code:public void decryptFile() throws Exception { assetsLoaded (); controlKey (); FileReader fr = new FileReader (this.filePath); BufferedReader in = new BufferedReader (fr); FileOutputStream fo = new FileOutputStream (this.outputPath); BufferedOutputStream out = new BufferedOutputStream (fo); int binary; int counter = 0; String codeToken = ""; while ((binary = in.read ()) != -1) { codeToken = codeToken + ((char) binary); System.out.println ("------------");//DEBUG if (counter++ > CODESPERCHAR) continue; System.out.println (codeToken);//DEBUG //out.write ((int)decrypt (codeToken)); codeToken = ""; counter = 0; } in.close (); out.close (); }
- 12-05-2011, 11:36 PM #2
Member
- Join Date
- Oct 2011
- Posts
- 90
- Rep Power
- 0
Re: Condition ignored.
Where is CODESPERCHAR defined?
- 12-05-2011, 11:45 PM #3
Re: Condition ignored.
in an other class(its a instance variable). I have initiated it to 3 in the constructor.
Actually, I used wrong variable. I am suppose to use CODELENGTH(3) instead of CODESPERCHAR(30). I changed it, but the problem remain the same.
CODELENGTH is also initiated in the constructor.Last edited by Pojahn_M; 12-05-2011 at 11:48 PM.
- 12-05-2011, 11:45 PM #4
- 12-05-2011, 11:46 PM #5
- 12-06-2011, 12:04 AM #6
Re: Condition ignored.
I am pretty sure it is ignored, or eclipse is fucking up(its not the first time it fuck up).
Java Code:if (counter++ > CODELENGTH) { System.out.println ("I am not ignored"); continue; }
I have access to it because the variables access is protected and not private.
- 12-06-2011, 12:12 AM #7
Re: Condition ignored.
That means that the if statement is ALWAYS evaluating to false. It is NEVER ignored.
- 12-06-2011, 12:20 AM #8
Re: Condition ignored.
you woke me up. thanks(and stupid me).
- 12-09-2011, 03:21 AM #9
Re: Condition ignored.
Similar problem.
The if statementat line 29 is always false. The block in line 30 to 33 is never executed. I cant see why.
passwords.length is 3.
Java Code:public void scrambleFile (int... passwords) throws IOException { if (0 >= passwords.length) throw new IllegalArgumentException ("At least one value"); this.extension = "cry"; setFileName (); BufferedInputStream in = new BufferedInputStream (new FileInputStream (this.inputFile)); DataOutputStream out = new DataOutputStream (new BufferedOutputStream (new FileOutputStream (this.outputFile))); int number = 0; int counter = 0; boolean addition = (passwords[0] > 100) ? true : false; while ((number = in.read ()) != -1) { if (addition) { out.writeInt ((number + passwords[counter])); addition = false; } else { out.writeInt ((number - passwords[counter])); addition = true; } if (++counter > passwords.length) { System.out.println ("Increasing: " + counter); continue; } System.out.println ("Reset"); counter = 0; } in.close (); out.close (); }
Reset
Reset
Reset
Reset
Reset
Reset
...
Similar Threads
-
Waiting on a condition
By nephos in forum New To JavaReplies: 9Last Post: 04-22-2011, 11:05 AM -
basic condition
By ts96 in forum New To JavaReplies: 1Last Post: 02-16-2011, 01:23 PM -
While loop condition
By counterfox in forum New To JavaReplies: 3Last Post: 10-10-2010, 02:14 AM -
IF-Condition in a String
By lenaz in forum Advanced JavaReplies: 1Last Post: 07-18-2009, 01:07 PM -
problem with using string in if condition
By sireesha in forum New To JavaReplies: 2Last Post: 11-20-2007, 11:40 PM
Bookmarks