Results 1 to 3 of 3
  1. #1
    crank6015 is offline Member
    Join Date
    Mar 2011
    Posts
    8
    Rep Power
    0

    Default 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

    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();		
    	}
    i need this method to clear special chars from downloaded url.
    the input is about 50000 chars

    thank you for any help...

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    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();
        }
    }

  3. #3
    crank6015 is offline Member
    Join Date
    Mar 2011
    Posts
    8
    Rep Power
    0

    Default

    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

  1. System.out.println not printing, weird output
    By KonchShell in forum New To Java
    Replies: 9
    Last Post: 03-16-2011, 11:50 AM
  2. Weird problem with 36 and 39?
    By jh7468 in forum New To Java
    Replies: 3
    Last Post: 02-06-2011, 08:01 PM
  3. System.out.println problem
    By luke in forum New To Java
    Replies: 5
    Last Post: 10-05-2010, 07:45 PM
  4. Weird problem with JSTL
    By Diego_Dalmasso in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 03-02-2010, 02:51 PM
  5. weird problem
    By GPB in forum New To Java
    Replies: 2
    Last Post: 02-28-2010, 12:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •