Results 1 to 3 of 3
Thread: weird problem with println
- 03-19-2011, 11:35 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 8
- Rep Power
- 0
weird problem with println
hello, i have this weird problem, i built a method to replace all non letter charecters with blank space, when i put small string it works perfectly, but when i put large string into it, it wont print the result (system.out.println), but when i place the method output into txt file, it writes it just fine . but later when i try println from the file it wont print either.
here's the method, maybe you can tell me what i'm doing wrong
i need this method to clear special chars from downloaded url.Java Code:public static String clearTokens(String text){ String lowerCase = text.toLowerCase(); StringBuilder buf = new StringBuilder( text ); for(int i = 0 ; i< lowerCase.length() ;i++ ){ if((lowerCase.charAt(i)< 'a') || ( lowerCase.charAt(i)>'z' )){ buf.setCharAt(i,' '); } } return buf.toString(); }
the input is about 50000 chars
thank you for any help...
- 03-20-2011, 12:18 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,546
- Rep Power
- 11
If you are running the program from within an IDE it might object to a line 50k characters long.
Eclipse certainly does. The following creates a one line file but nothing appears in the IDE's console.
Java Code:import java.io.File; import java.io.FileWriter; public class StringCleaner { public static void main(String[] args) throws Exception { StringBuilder buf = new StringBuilder(); for(int i = 0; i < 50000; i++) { char ch = (char)('a' + (i % 26)); buf.append(ch); } System.out.println(buf); FileWriter out = new FileWriter(new File("c:/longString.txt")); out.write(buf.toString()); out.close(); } }
- 03-20-2011, 12:38 AM #3
Member
- Join Date
- Mar 2011
- Posts
- 8
- Rep Power
- 0
thanks,
i use eclipse, i tought so to, but the weird thing is, when i try to print the original string with the special chars, it prints it just fine on screen, but when i clean the string with this method, it goes crazy, and wont show me a thing on screen, tried to run it in debug step by step, at first all works fine, but something in the loop makes him go crazy :confused:
thanks for the replay anyway, i think i'll just split the string to array, and run cell by cell :o
Similar Threads
-
System.out.println not printing, weird output
By KonchShell in forum New To JavaReplies: 9Last Post: 03-16-2011, 11:50 AM -
Weird problem with 36 and 39?
By jh7468 in forum New To JavaReplies: 3Last Post: 02-06-2011, 08:01 PM -
System.out.println problem
By luke in forum New To JavaReplies: 5Last Post: 10-05-2010, 07:45 PM -
Weird problem with JSTL
By Diego_Dalmasso in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 03-02-2010, 02:51 PM -
weird problem
By GPB in forum New To JavaReplies: 2Last Post: 02-28-2010, 12:04 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks