java - Cannot print out result -
i try print out text: aloha prints nothing out while if delete loop right above text, prints. can explain me? in case, if want keep loop (for(s=5; s<0;--s)), how can make work? thanks
import java.io.*; public class email13 { static boolean isvalidemailcharacter(char c){ boolean result = false; if((c>='a'&&c<='z')||(c>='a'&&c<='z')||(c>='0'&&c<='9')||(c=='.')||(c=='-')||(c=='+')) result = true; return result; } public static void main(string[] args) throws exception{ bufferedreader cin, fin; cin = new bufferedreader(new inputstreamreader(system.in)); //description system.out.println("programmer: minh nguyen"); system.out.println("description: program start final project."); system.out.println(); string namein, nameout, dein, deout; namein=""; nameout=""; dein = "filecontainingemails.txt"; system.out.print("enter input filename [default:" + dein + "]: "); namein = cin.readline(); if(namein.compareto("")==0){ namein = dein; deout = "copypastemyemails.txt"; system.out.print("enter output filename [default:" + deout + "]: "); nameout = cin.readline(); if(nameout.compareto("")==0) nameout = deout; } else if(namein.compareto("")>0){ deout = namein; system.out.print("enter output filename [default:" + deout + "]: "); nameout = cin.readline(); if(nameout.compareto("")==0) nameout = namein; } fin = new bufferedreader(new filereader(namein)); //read input file while(true){ if(!fin.ready()) break; string linefromfile; linefromfile = fin.readline(); int s, e, hasdot, count; count = 0; (int = 0; < linefromfile.length(); i++) // each char in string... { if(linefromfile.charat(i)=='@'){ for(s=5; s<0;--s) system.out.println("aloha"); } } } fin.close(); printwriter fout; fout = new printwriter(new filewriter(nameout)); fout.close(); } }
s
not less 0, never enters loop
for(s=5; s<0;--s)
just make
for(s=5; s>0;--s)
Comments
Post a Comment