Writing to file with specific encoding in unix

hi,
I want to write html files which contain Turkish characters in unix operating system.
I'm currently using FileWriter to write the files.
I'm getting the file content from the database and I can see that the characters seem to be fine but when I write them into an html file, they are displayed with the question mark character (?).
What can I do about this?
Thanks

FileWriter uses the default character encoding of whatever platform your program is running on. Beside the fact that the default encoding may vary from one machine to another, it may not be suitable for storing non-ASCII (Turkish) characters.
Rather than using FileWriter, you can use an OutputStreamWriter and a FileOutputStream, which allows you to specify the character encoding you want. UTF-8 is generally a good choice, since it can encode just about anything. For example:FileOutputStream fos = new FileOutputStream("/some/file/name");
OutputStreamWriter osw = new OutputStreamWriter(fos, "utf-8");
osw.write("your text with Turkish characters...");Geoff

Similar Messages

  • Uploading data file with specific encoding and other metadata

    Hello everyone.
    I've been recently testing Microsoft Codename "Data Hub". When select the option to upload a CSV or XLSX file to populate my database, it basically has two problems, in my opinion:
    1. It would be great if I could select the file's encoding. If my file is in Spanish, it won't properly load latin characters (e.g. accents, or special characters). The information ends up showing with a bunch of weird characters.
    2. It also doesn't let me select which character to use as data separator. It uses the comma as the default. Some of the data might contain commas, so I usually change the separator to a pipe in my CSV files.
    Does anybody know any workarounds?
    Thanks.

    Hey there, and apologies.  I wanted to reach out and see if this is still a problem for you.
    I also wanted to check if this is a question about Azure SQL Database or something else?
    Thanks Guy

  • Writing a report file with specific information

    Hi, all:
    I need to write a text file with specific information in it. I'm going to copy it into Excel, so the easier the format, the better (perhaps CSV format?). I've never done this before, so here's the method I need to capture the information from:
         public void step() {
              greenColorStorage = new ArrayList();
              magentaColorStorage = new ArrayList();
              System.out.println( "==> Model step " + getTickCount() );// Checking step #
              for (int i = 0; i < soldierList.size (); i++) {
                   Soldier s = (Soldier) soldierList.get (i);
                   s.step();
              Collections.shuffle(soldierList);
              System.out.println("Shuffling collection now.");
              dsurf.updateDisplay ();
              System.out.println("Model.step() finished.");
              for (int i = 0; i < soldierList.size (); i++) {
                   Soldier s = (Soldier) soldierList.get (i);
                   if (s.getMyColor() == Color.green ) {
                        greenColorStorage.add(s);
                   if (s.getMyColor() == Color.magenta ) {
                        magentaColorStorage.add(s);
              if (magentaColorStorage.size() == 0 || greenColorStorage.size() == 0 ) {
                   stop();
         }In this method, I need to capture this information: There are soldiers on the Green team and on the Magenta team. I need to know how many there are originally, how many in this time step, at what time step the model stops, and how many of the winning color team are left when the model stops. How do I do this? If you can point me to a specific thread that shows how to write a report file like this, I'd be grateful, since I couldn't find one when I searched. Otherwise, I'd be grateful for examples. I'm in the middle of doing some research, and I have the feeling that I'll need to write report files in the future, so if you'd explain any code you provide, I would be quite grateful--I need to understand what I'm doing as well as simply using your code so that I can really learn what I'm doing when I do this again. Thanks very much!

    FileOutputStream
    public FileOutputStream(File file,
                            boolean append)
                     throws FileNotFoundException
    Creates a file output stream to write to the file represented by the specified File object.
    If the second argument is true, then bytes will be written to the end of the file
    rather than the beginning.
    */

  • How to create PDF from text file with specific layout?

    I wanted to create the pdf from text file in specific layout - Landscape orientation and JIS B3 Page size while at Adobe Acrobat Pro.
    In past, I could do a right click on a text file (desktop area) and select print to print out the document into .pdf BUT only if I set the Adobe PDF to Landscape and JIS B3 Page size BEFORE.  And I could only do 15 text documents at once.
    I wanted to see if I could do the create the pdf from text file with specific layout in Adobe Acrobat without having to go to Control Panel to preset the Adobe PDF to specific layout at every time.   I would have to set Adobe PDF back to normal layout after I'm done with these pdf print outs.  I do lots of pdfs in normal layout.  Sometimes I would forget to do that.
    So, How do I do that?

    No such luck.  It would output the contents in letter size even in JIS B3 Page layout at MS word. 
    Is there a script or action where I could set the orientation and page size before creating PDF on these text files?

  • Suppress writing cache files with rwrun.exe

    Hello,
    we`re using rwrun.exe (9.0.4.2.0) with parameters to create pdf-files in a loop:
    REPORT=mytest.rdf
    USERID=scott/tiger@orcl
    BLANKPAGES=no
    DESTYPE=file
    DESNAME=mytest.pdf
    DESFORMAT=PDF
    OUTPUTIMAGEFORMAT=GIF
    CACHELOB=NO
    Each process write a cache file in the directory …\reports\cache. Reports eats the hard disk :-(
    I`ve found the EXPIRATION command in the documentation, which defines the point in time when the report output should be deleted from the cache. But this command strictly runs with rwclient.exe and reports server, but Reports server isn`t installed on our server.
    Can we suppress writing cache files with rwrun.exe?
    Steffen

    Hello,
    Why don't you add a command del in your loop ?
    Example:
    del %ORACLE_HOME%\reports\cache\*.*
    Regards

  • Outbound interface - Generating files with ANSI encoding.

    Hi All,
    I am able to generate output files with txt extension. But it is generating in UTF-8 encoding files, myself when i open the files in notepad, i find UTF-8 and when opened in wordpad i find ANSI. My user wants it in ANSI in any case.
    One more thing my client's language is Spanish, where there will be special characters like Ñ, so if the file is in ANSI, will there be a problem for this characters.
    Please help.

    So which OS is to blame? The Mac seems to be inserting weird paragraph returns that Windows doesn't understand, no matter what type of file encoding you use (UTF-8, Western Windows Latin 1, Western DOS Latin 1).
    My understanding is that TextEdit uses standard Unix type line endings, called LF (line feed, hex 0A). Windows stuff uses a different convention, CR + LF (0D 0A). If a Windows app will not display text just because it encounters something other than CR + LF, I'd say it probably has a bug of some sort.
    Is there a solution to this probem?
    I don't think the line endings of TextEdit can be changed. Some other apps like Text Wrangler offer you a choice in their preferences.

  • DNxHD 709 Files with Media Encoder

    I have mutliple MOV Files with this codec.
    I have to export them as MXF (XDCAM).
    Media Encoder can not handle this color space so my black level is to high.
    Is there a way to get it right there or must I go through Premiere or AE to adjust the levels and batchexport it out of this?

    Let's try to sort it out:
    1. Non-'colour aware' (non-'colour manageable') application does not work in any colour space, rather in 'nowhere'. It does not apply any correction/transformation to colour data and simply transfers them from a media file to a display or in case of transcoding - to another media file.
    Since waveforms are identical for both your source file and a transcoded one, you're not facing any glitches during transcoding. Therefore, feel free to transcode all your DNxHD MOVs into XDCAM MXFs via AME, if you want to.
    2.  In most cases you don't need to assign a specific colour profile to a video file. If you do, you should utilise colour aware application for handling them further in your pipeline (e.g. After Effects).
    Meanwhile, sRGB, which might be the working space of your monitor, and Rec.709 are quite close. In gamma corrected environment you can hardly see any difference between them.
    3. If you feel the need to adjust anything from colour range to hue etc. etc., you should use your editing/compositing application, not just an encoder.

  • Writing Datalog Files with record length

    How do I write a Datalog File with a record length of 128 int16s?

    Each I16 number in LabVIEW that you write uses 2 bytes because 8 bits equals 1 byte. If you write 128 numbers, the file will be 256 bytes long. You can modify the VI to write I32 (4 bytes) or I8 (1 byte) just by changing the representation of the number. You also need to change the subVI that does the actual writing (Write File+ [I16].vi). Be sure to rename the VIs that you change. I would think that your Fortran program would work as long as the data types match.

  • Open vi file with specific Labview version using batch file (Windows)

    I want to open certain vi with using Windows batch file and to use specific version of Labview development system. I tried
    "C:\Program Files (x86)\National Instruments\LabVIEW 2012\LabVIEW.exe" "path_to_vi"
    "C:\Program Files\National Instruments\LabVIEW 2012\LabVIEW.exe" "path_to_vi"
    to use 32-bit and 64-bit development systems respectively. However Labview opens file with version which was last used before. Are there any ways to force it use specified version?

    No, it's a VI I wrote so that when I open any VI from Windows Explorer it will open it in correct version of LabVIEW according to it's source version (rather than the latest/last version of LabVIEW I opened). All it does to launch the right version of LabVIEW is to call System Exec with the path to the correct version of the LabVIEW.exe and the path to the VI - which is essentially the same as what your batch file is doing.
    Certified LabVIEW Architect, Certified TestStand Developer
    NI Days (and A&DF): 2010, 2011, 2013, 2014
    NI Week: 2012, 2014
    Knowledgeable in all things Giant Tetris and WebSockets

  • Writing to file with ObjectOutputStream

    ApartmentWriterProgram asks information about apartments
    and saves it to a file.
    For some reason it doesnt save information, it writes:
    Writing to file "+file+ " failed.
    So there happens IOException in the method write(Apartment apartment).
    Or in the run().
    I dont know what's wrong. Do you?
    public class ApartmentFileHandler extends Object implements Serializable {
        private OutputStream outStream;
        private ObjectOutputStream obStream;
        private String filePath;
            public ApartmentFileHandler(String filePath) {
               this.filePath = filePath;
    /** Writes the given apartment data in the file. If the file already
    exists, the old contents are overwritten.
    Parameters:
    apartment - the apartment to be written in the file
    Throws:
    IOException - if other problems arose when handling the file (e.g. the
    file could not be written)
            public void write(Apartment apartment)
               throws IOException {
               outStream = new FileOutputStream(filePath);
               obStream = new ObjectOutputStream(outStream);
               obStream.writeObject(apartment);
    import java.io.*;
    import java.util.*;
    public class ApartmentWriterProgram
    extends Object
        private KeyboardReader keyboardReader;
        private List roomsInList;
        private Room[] rooms;
        private int numberOfRooms;
        private String file;
              public ApartmentWriterProgram()
                this.keyboardReader = new KeyboardReader();
                this.roomsInList = new ArrayList();
                this.rooms = new Room [numberOfRooms];
    /** Runs the writer program. The program asks the user for some
    apartment data and a file name, and saves the data in the file. */
              public void run() {
                try {
                  numberOfRooms = keyboardReader.getInt("Give number of rooms: ");
                  for (int i =1; i<numberOfRooms+1; i++) {
                     String type =keyboardReader.getString("Give " +i+ ". " + "type of the room: ");
                     double area =keyboardReader.getDouble("Give " +i+ ". " + "area of room: ");
                     Room room= new Room(type, area);
                     this.roomsInList.add(huone);
                  roomsInList.toArray(rooms);
                  Apartment apartment = new Apartment(rooms);
                  System.out.println();
                  file = keyboardReader.getString("Give name of the file: ");
                  ApartmentFileHandler handler = new ApartmentFileHandler(file);
                  handler.write(apartment);
               } catch (IOException ioe) {
                 System.out.println("Writing to file "+file+ " failed.");
             public static void main(String[]  args) {
                  ApartmentWriterProgram program = new ApartmentWriterProgram();
                  program.run();
    }

    There is nothing to gain in not putting the throws IOException in the write method, since the exception object will have the information about the actual problem.
    Is this a typo for the this post?                 this.roomsInList.add(huone); should be room nes pas.
    What exception is actually thrown? To find out useSystem.out.println("Exception: " + ioe);Then wonder why you have the AppartmentFileHandler implement Serializable when you are not writing that object to the file.

  • Trouble writing to file with FileWriter

    Hey I'm pretty new to Java and even newer to file classes so I'd appreciate it you could look over what I've done. My FlashCard object has its own toString() method which prints out what I want it to so basically all I need to know is why it doesn't print anything?
    File f;
    //..Constructors and other methods for a JFrame
         private void printList() throws IOException
                   writer = new PrintWriter(new BufferedWriter(new FileWriter(f)), true); //f is a File object declared below
                   writer.println("test");
                   java.util.Iterator<FlashCard> e = cards.iterator();
                   String s = "";
                   while(e.hasNext())
                        s = "" + e.next();
                        writer.println(s);          
                        System.out.println(s);   //Debugging line, prints out what i want to be put in the file correctly!
                   writer.close();
                   FileWriter writer2 = new FileWriter(f, true);
                   writer2.write("hi");
    //....more code
    private class ClickListener                          //subclass of the class containing the code above
                   implements ActionListener
                   @Override
                   public void actionPerformed(ActionEvent e)
                        if (e.getSource() == create)
                             boolean temp = false;
                             String fileName = "c:\\FlashCards\\";
                             f = new File(fileName);
                             f.mkdir();
                             f = new File(fileName + stackName.getText() + ".txt");
                             try {
                                  temp = f.createNewFile();
                             } catch (IOException e1) {
                             //...More code here for responding to file not being created successfully
                             f.setWritable(true);
                             control.currentFile = f;
                        }This the the only code I thought to be relevant but if there's a declaration you need that I left out let me know! The annoying thing is I copied this from another class I wrote (with modifications of course) and it works perfectly, no problems!
    Thanks in advance!

    OK I've done the things you've mentioned, thank you for me notice i was missing some code organization. The problem unfortunately is not yet solved but now I think I have a better idea of what the problem is! Here's the code:
    This is what I'm using to make a file
    private void createFile()
                   boolean temp = false;
                   String fileName = "c:\\FlashCards\\";
                   f = new File(fileName);
                   f.mkdir();
                   f = new File(fileName + stackName.getText() + ".txt");
                   try {
                        temp = f.createNewFile();
                   } catch (IOException e1) {
                        //TODO fill in exception catchs
                   if(temp)
                        //Do something
                   else
                        JOptionPane.showMessageDialog(addCard, "File Name Already Exists");
                        return;
              }And this is where the file is being used by a writer:
              private void printList() throws IOException
                   String temp = f.getAbsolutePath();
                   PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(new File(temp), true)), true);
                   java.util.Iterator<FlashCard> i = cards.iterator();
                   while(i.hasNext())
                        writer.println(i.next());          //TODO fix this writer so that it prints properly onto the document!!
                   writer.close();
              }The problem I think is either caused by a) the new File doesn't like properly to the FileWriter for some reason or b) the file I've made does not work for output for some reason. I think this because I can make a new file with a literal pathname such as "c:\\file.txt" and it works fine but as soon as I use my file f to make it it doesn't print anything out!! any ideas?

  • Writing a file with the OutputStream

    I'm trying to upload a file using Java's included ftp functionality.
    currently I'm trying to figure out how to upload a file. The connection and works.
    The code I found for the ftp connection indicated that I should use the following code to upload..
    URLConnection urlc = url.openConnection();
    OutputStream os = urlc.getOutputStream();
    I've read the documentation for the outputstream and looked for help tutorials on the web etc, but still haven't been able to figure out what I'm doing.
    I need the output stream to write a file to the ftp server. I can get it to put a file there, but so far its just been an empty file. How do I get it to actually write the file with its contents etc.
    thanks for the help

    never mind :) I think I figured it out.
    I just created a File object for the file, then opened a fileinputstream to read the file in and wrote that output using the output stream.
    it seems to work.

  • HOW TO: Open SQL Developer from a batch file with specific tables opened

    I use SQL Developer daily as I develop database intensive programs.
    ** Question **
    How can I define a specific configuration of tabs (i.e. tables, procedures, etc) to be opened upon startup of SQL Developer?
    For example, creating a .BAT file to open SQL Developer with a specific set of table tabs already opened. This will save me the time every morning I use to open SQL Developer and configure all the tables I need opened.
    NOTE: I have tried various options of appending a table name to a command line starting sqldeveloper.exe. For example: ..\sqldeveloper.exe mydatabase.mytable. However, this only opens a worksheet tab with the name "mydatabase.mytable" but does not open my actual table.
    Any help will be appreciated.
    - Gary Davis

    what version are you using? Sql Dev 1.5?
    Not an exact answer, but you could try using Table FILTER
    click on your connection
    right button on TABLES
    click apply filter
    as for your question, check out:
    Re: EA1 - Automatically open connection list at startup?
    or
    SQL Developer

  • OSB file Write, not naming the file with specific name.

    Hi ALL,
    I have a requirement, i should accept the data or XML file from from JMs queue and place it in a location specified. For this i have build the PS and BS.
    Where PS will De-queue the JMS queue and route using Service call out to BS. And the BS will place the file in location. I could do this easily. BUT the thing is that i could not name the file perfectly with the intended file name. to build the BS i used .JCA file , .WSDL file, XML file from Jdeveloper. and imported to osb console. i could write the file as follows..
    MY business Services:
    services TYPE : ANY XML services
    transport
    Protocol ==> file
    Load Balancing Algorithm ==> round-robin
    Endpoint URI ==> file:///oracle/Middleware/user_projects/domains/Agile
    Request encoding ==> utf-8
    this is the file name i am getting:
    <con:metadata      xmlns:con="http://www.bea.com/wli/sb/test/config">
         <tran:response-code      xmlns:tran="http://www.bea.com/wli/sb/transports">0</tran:response-code>
         <tran:encoding      xmlns:tran="http://www.bea.com/wli/sb/transports">utf-8</tran:encoding>
         <file:filePath      xmlns:file="http://www.bea.com/wli/sb/transports/file">
         /oracle/Middleware/user_projects/domains/Agile/POTest3338620552690675292--411054fa.1363686ca89.3e8d.xml
         </file:filePath>
    </con:metadata>
    the file NAME : POTest3338620552690675292--411054fa.1363686ca89.3e8d.xml ( POTest is prefix and .xml is Sufix)
    3338620552690675292--411054fa.1363686ca89.3e8d i dont know y the this garbage file name is created...
    please give suggestions to avoid garbage name
    thanks --
    ANIL

    Hi ALL,
    I have a requirement, i should accept the data or XML file from from JMs queue and place it in a location specified. For this i have build the PS and BS.
    Where PS will De-queue the JMS queue and route using Service call out to BS. And the BS will place the file in location. I could do this easily. BUT the thing is that i could not name the file perfectly with the intended file name. to build the BS i used .JCA file , .WSDL file, XML file from Jdeveloper. and imported to osb console. i could write the file as follows..
    MY proxy services:
    services type : any XML services
    protocol :jms
    MY business Services:
    services TYPE : ANY XML services
    transport
    Protocol ==> file
    Load Balancing Algorithm ==> round-robin
    Endpoint URI ==> file:///oracle/Middleware/user_projects/domains/Agile
    Request encoding ==> utf-8
    this is the file name i am getting:
    <con:metadata xmlns:con="http://www.bea.com/wli/sb/test/config">
    <tran:response-code xmlns:tran="http://www.bea.com/wli/sb/transports">0</tran:response-code>
    <tran:encoding xmlns:tran="http://www.bea.com/wli/sb/transports">utf-8</tran:encoding>
    <file:filePath xmlns:file="http://www.bea.com/wli/sb/transports/file">
    /oracle/Middleware/user_projects/domains/Agile/POTest3338620552690675292--411054fa.1363686ca89.3e8d.xml
    </file:filePath>
    </con:metadata>
    the file NAME : POTest3338620552690675292--411054fa.1363686ca89.3e8d.xml ( POTest is prefix and .xml is Sufix)
    3338620552690675292--411054fa.1363686ca89.3e8d i dont know y the this garbage file name is created...
    i am getting this error when i process test from proxy services then i may use route and change it as Use Routing Options on the Service Callout and override the header (jca.file.FileName).
    but the thing is when i test from Business services also i am getting the same garbage name on both window and linux.
    please give suggestions to avoid garbage name
    thanks --
    ANIL

  • Importing data from third party file with specific layout

    Hello everyone,
    I have been searching the forum and googling for help on this but so far no success.
    The issue I have is the following:
    - I need my client to provide data to me in 2 different dates (Date 1 and Date 2), for example, a bank account balance;
    - He has already provided me with data for "Date 1" in the previous year and this information is stored in a file, generated by a government software;
    - I have the file layout provided by the government, establishing the location and number of characters where the information is stored (e.g. need to import characters 4-12 of a specific line in the file);
    - I need to be able to read from this file and pre-populate field "Date 1" with the amounts informed previously;
    - I will then send a PDF form for him to update the "Date 2" field, using the amount in "Date 1" as a reference.
    Is there any way I can do this?
    I like researching and do this as a hobby, therefore I don't expect to receive pieces of code already prepared - I would just appreciate if anyone could point me in the right direction here, as my coding skills are from a guy interested in learning things.
    Many thanks in advance for all the help.
    P.S.: the government software can generate a .PDF file and the data I need is reported there, just in case it is easier to work with a PDF file instead.

    Hi,
    Looks like that you are using relative path. Then, the file must be located in MathScript search path. Otherwise, MathScript can not find that file. You can either specify the absolute path or add the path to MathScript search path list.
    I have tried in LabVIEW 8.6. dlmread should work well to read data from .txt file.

Maybe you are looking for

  • Problem in XI in my laptop

    Hi Gurus,    I have installed XI in my laptop.It worked fine for 10 days.Now its giving some date problem.It seems,the license will be expired on so and so date. My question is that,if i change the date to the back date,will be java engine gives any

  • Deploying in cluster env

    HI, we have a clustered env for our production system. i defined a track and set up the runtime systems. since our production box is a clustered environoment, i specified the SDM hostname as the host on which the central instance is running. so when

  • RMAN-20207: UNTIL TIME or RECOVERY WINDOW is before RESETLOGS time

    Hello, i am working for a scenerio and you can see my restore script below, RMAN> RUN 2> { 3> SET UNTIL TIME "to_date('24-05-2010 18:00:00','DD-MM-YYYY HH24:MI:SS')"; 4> RESTORE DATABASE; 5> RECOVER DATABASE; 6> } executing command: SET until clause

  • Reg control flow

    I have an message statement of type error, After the message statement I have another executable statement. How to change the control flow from after displaying the error message to that executable statement. thnks in advance. Edited by: jean liker o

  • Profit Center change in Sales Order by Profit Center reorganization

    Dear FI gurus I have requirement to change profit center in sales order in mass. I heard in EhP5, there is function called "Profit Center Reorganization". For my requirement, this function can be used? If not, what is this functionality? Yoshi