When I copy a line in txt file such as 7318912227725338960527291316 and paste into Word, it pastes a column instead of a row such as


This happens in both my Windows 7 and Mac. I'm trying to do a java homework that reads from this text file but this is confusing...

| |
  • Does it always switch 4th and 5th character in the process? – techraf Jan 27 '16 at 0:15
  • 1
    You haven't said where you get your text from. If it came from a web-site there could be formatting within the text on the page. Does it paste OK into notepad? If so, copy from there. This will eliminate any unprintables from the text. – AFH Jan 27 '16 at 0:25
  • it's from my teacher's website.. yes, it pastes Ok when I put in another txt file.. I was confused for the whole day... Thanks so much – 33ted Jan 27 '16 at 0:52
  • if you open it in Notepad++ or a simmilarly feature-rich editor, and tell it to show formatting marks, and check to see if there are non-printable characters. Have you confirmed with your instructor whether the data is one 28-digit number or 10 numbers of less than 999? the later seems more likely as your homework is to read from a file, and reading multiple lines is likely part of the exercise. – Frank Thomas Jan 27 '16 at 4:25

I guess that "txt" file has unix line endings (0x0A, \n) and you are opening that file with MS Notepad, which expects DOS line endings (0x0D 0x0A, \r\n), and then it shows like one very long line.

Use e.g. Notepad++ instead of MS Notepad. Or even use MS Word itself to open that txt file.

Or ask the person that creates the file with \n line endings to use \r\n line endings. E.g. in linux convert the file with:

 unix2dos thefile.txt
| |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.