Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Writing txt file to unix

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So the problem is fixed now?

Notepad++ can certainly display UTF-8 files correctly.
 
Once upon a time there were three bears. And they were visted by a golden haired tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic