java - Delete point in the text document and create a new file -


i trying delete points in text document file, replacing empty string.

it not work although same works question mark.

sample:

... ... ... ... ... ... ... ... ... ... stephensonstraße 07:10 07:40 08:13 ... ... ... universitätsklinikum 04:36 05:06 05:39 06:25 06:57 07:27 07:57 08:27 08:57 11:57 ... ... ... ... ... grönauer baum 05:43 06:29 07:02 07:32 08:02 08:32 09:02 12:02 ... ... ... ... ... 

code

private static void replace_word() {      file file = new file("d:\\hl_sv\\l09mf.txt");     try (printwriter writer = new printwriter("d:\\hl_sv\\l09mf2.txt");             scanner scanner = new scanner(file)) {             while (scanner.hasnextline()) {                 string line = scanner.nextline();                 writer.println(line.replace('?', '-'));                 writer.println(line.replace('.', ' '));         }     } catch (exception e) {         e.printstacktrace();     } } 

you writing 2 versions of same line output. 1 have "?" removed, not points. other vice versa. output contain twice number of lines input - intention?

if want same output lines, replaced "?" , ".", should build output line contains conversions before writing:

string line = scanner.nextline(); string outputline = line.replace('?', '-'); outputline = outputline.replace('.', ' '); writer.println(outputline); 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -