Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to remove '0A' from string?
    primarykey
    data
    text
    <p>I am trying to read a text file, line-by-line and concatenate the lines to create a single string. But while creating that unified string, <code>0A</code> is being added after each line. The string itself is just one line and I cannot see the <code>0A</code> in normal text/Java editor, but when I open it in an Hex editor, I can see '0A' after each line. I am working on a Linux (Ubuntu) platform.</p> <p>I have tried every possible thing to remove them, specifically <a href="https://stackoverflow.com/questions/6870858/java-how-to-remove-carriage-return-hex-0a-from-string">Java How to remove carriage return (HEX 0A) from String?</a></p> <p>But I am not able to remove them. Any thoughts about how to do this?</p> <p><strong>UPDATE:</strong></p> <pre><code>File workingFolderLocal = new File("src/test/resources/testdata"); String expected = "String1"; MyClass myClass = new MyClass(); myClass.createPopFile(workingFolderLocal); // Read the created file and compare with expected output FileInputStream fin = new FileInputStream(workingFolderLocal + "/output.xyz"); BufferedReader myInput = new BufferedReader(new InputStreamReader(fin)); StringBuilder actual = new StringBuilder(""); String temp = ""; while ((temp = myInput.readLine()) != null) { String newTemp = temp.replaceAll("\r", ""); actual.append(newTemp); } System.out.println("actual: " + actual.toString()); myInput.close(); Assert.assertEquals(expected, actual); </code></pre> <p>Here is the output/error I am getting:</p> <pre><code>actual: String1 FAILED: testCreatPopFile junit.framework.AssertionFailedError: expected:&lt;String1&gt; but was:&lt;String1&gt; at junit.framework.Assert.fail(Assert.java:47) at junit.framework.Assert.failNotEquals(Assert.java:277) at junit.framework.Assert.assertEquals(Assert.java:64) at junit.framework.Assert.assertEquals(Assert.java:71) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload