• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Writing txt file to unix

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

I have a problem writing a file generated by a java ( 1.4.2) applicationin unix.
Basically the app will generate a txt file,using the class FileUtils, to a unix folder. The objective is to download the file and view it in windows.
The encoding i´m using when writing occurs in unix is UTF-8.
When i download the file some characters like ´ ~ ^ are encoded and aren´t correctly displayed.
Why?
What can i do to correct this behaviour?

Any help appreciated
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

How exactly are you downloading the file and how are you displaying it? Are you displaying it in a browser window, text editor, or in the Windows command prompt? Are you reading the file in your Java program? Have you specified that the file has to be interpreted as UTF-8?

You need to make sure that whatever you use to display the file understands the UTF-8 encoding and can show you the characters correctly.

To read an UTF-8 text file in Java, you can open it using an InputStreamReader and specify the character encoding, like this:
 
phasor james
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

For downloading the file i was using filezilla and editing it in notepad ++.
I was hardcoding a test string in java.the .java file was in ansi encoding. that was the problem.

Thanks
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the problem is fixed now?

Notepad++ can certainly display UTF-8 files correctly.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!