Home > Back-end >  For bosses to solve! Too read Java file the replacement of a new line
For bosses to solve! Too read Java file the replacement of a new line

Time:09-26

The code is:
String STR="";
The File outcontent=new File (" F: "+ File. The separator +" example. TXT ");
FileInputStream in=new FileInputStream (outcontent);
Int size=in. The available ();
Byte [] buffer=new byte [size];
In the read (buffer);
In the close ();
STR=new String (buffer);

One example. TXT file including line breaks
If at the end of the program to join
STR=STR. Replace (" \ n ", "");
The last line in the STR \ n and its characters are not before the
Excuse me how can I replace a newline right and will not affect the other characters, beg bosses to disabuse

CodePudding user response:

Use the subString method remove the last character and empty

CodePudding user response:

reference 1st floor KeepSayingNo response:
use the subString method remove the last character then empty

But it can only remove the newline at the end of the article, I want to do is to put all of the line are replaced with another string, not just remove

CodePudding user response:

The lines you read it, then remove rows
  • Related