Writing non-latin Character to Log file from Java application

Hi Everyone,
I'm encountering a very strange localization issue.
I'm executing the following code from a J2EE application (although the behavior is replicated exactly from a Java console application):
File testFile = new File("D:\\Temp\\blah.txt");
testFile.createNewFile();
Writer output = null;
try {
output = new BufferedWriter( new FileWriter(testFile) );
output.write( "אחד שתיים שלוש" ); // Non-Latin characters
output.write("one two three");
finally {
if (output != null) output.close();
I'm writing non-latin characters (Hebrew in my case) to the file, but these characters are written as question marks:
??? ????? ????one two three
I'm running the project with the following java arguments:
-Dfile.encoding=UTF8 -Duser.region=IL -Duser.language=he
And the Project Properties -> Compiler -> Character Encoding = UTF8
Also, the local Windows Regional Settings are set to Israel / Hebrew.
Can someone please help with this issue?
I've tried this with UTF-8 (instead of UTF8) and still no results.
I suspect this is a Java / Environment issue as it reproduces on a J2EE app and on a console app.
Any help will be greatly appreciated.
Thanks,
Tal.

You should open/close it somehow at every write from different processes.
But I personally prefer different file names to your forced merging, though.

Similar Messages

  • Running exe files from java applications

    Hello All,
    Is it possible to run executable files from java applications?
    I need to run an exe file on the client from the server machine, the exe could reside on either the server or any other machine on the LAN. Is it possible to specify the path of where the exe resides, and run it on a client machine?

    HI,
    I tried to launch a MS Word application using runtime.exec but it gives me some problem
    The foll. code to launch a txt file using notepad works.
    Runtime rt = Runtime.getRuntime();
    String[] callAndArgs = {"notepad.exe","C:\\coo7\\wizard.txt"};
    Process child = rt.exec(callAndArgs);
    However, oif I try to launch a MS Word application, it asks for the entire path of WINWORD.exe, (unlike just specifying notepad.exe as the first argument in String[] callAndArgs) and this can vary from one machine to another.. how do I get around this?
    The foll. code snippet works but the complete path of where WINWORD.exe might be installed on any machine, is not fixed:-(
    Runtime rt = Runtime.getRuntime();
    String[] callAndArgs = {"C:\\Program Files\\Office\\Office10\\WINWORD.exe","C:\\coo7\\wizard.doc"};
    Process child = rt.exec(callAndArgs);
    Any idea/suggestions pls..

  • Java.util.logging: write to one log file from many application (classes)

    I have a menuapp to launch many applications, all running in same JVM and i want to add logging information to them, using java.util.logging.
    Intention is to redirect the logginginfo to a specific file within the menuapp. Then i want all logging from all applications written in same file. Finally, if needed (but i don't think it is), i will include code to write logging to specific file per app (class). The latter is probably not neccessary because there are tools to analyse the logging-files and allow to select filters on specific classes only.
    The applications are in their own packages/jars and contain following logging-code:
            // Redirect error output
            try {
                myHandler = new FileHandler("myLogging.xml",1000000,2);
            } catch (IOException e) {
              System.out.println("Could not create file. Using the console handler");
            myLogger.addHandler(myHandler);
            myLogger.info("Our first logging message");
            myLogger.severe("Something terrible happened");
            ...When i launch the menuapplication, it writes info to "myLogging.xml.0"
    but when i launch an application, the app writes info to "myLogging.xml.0.1"
    I already tried to leave out the creation of a new Filehandler (try/catch block in code above) but it doesn't help.
    Is it possible to write loginfo to same specific file?

    You should open/close it somehow at every write from different processes.
    But I personally prefer different file names to your forced merging, though.

  • Different languages used while uploading file from java Application

    Hi everybody,
    i have a problem with multiple languages , let me clear you the question, i were developing a java application using spring ,hibernate frame works, so i got a problem while uploading a file with chinees language or other
    it was saving with different format other than chiness in the database, can any one help me out ... i need the exact language when i upload the files,and when i get the data from DataBase which is in chinees language is '걨' going to be like as '???'
    thank you very much

    Santhosh_25 wrote:
    using utf-8 characterSet, but its not showing properly
    thank youOkay.. the problem with your browser settings.. (not sure)..
    In firefox try to set character encoding...
    go to View--->Character Encoding--->Unicode (UTF-8)..
    In IE
    go to View--->Encoding-->More-->Unicode (UTF-8)
    set this and try.

  • How to open an PDF file from Java Application

    Hi
    I am developing a GUI application in java swing.
    on clicking one button, I want to open PDF file from my swing application.
    Is there any API through which I can achieve this?
    Tapan Maru
    Sun Certified Java Programmer

    Here's a way to do it (if I understand you
    correctly). Just let explorer.exe do it for you.
    import java.awt.*;
    public class openPDF
         Desktop desktop = Desktop.getDesktop();
         public openPDF()
              open("test.pdf");
         public void open(String path)
              try
                   Runtime.getRuntime().exec("explorer.exe "+path);
    } catch(Exception e) { System.out.println("NAI!
    I! ERROR!\n"+e); }
         public static void main(String[] args)
              openPDF myApplication = new openPDF();
    Why do you have a Desktop object as a member but instead of using it, you execute a command with Runtime (which is not platform independent!)???
    -Puce

  • Write HTML Files from java application

    Hello,
    i have to write HTML files from a java application.
    I am asking if anybody can give me a hint about a good simple solution (library) which can do some of the job for me.
    i know FOP for example is good to create pdf or html from xml, but i dont want to go via xml.
    the sites i need are really very simple presents emails.
    body and maybe a link for next and pervious.
    however, thank you in advance.
    a little hint will also help :)
    Sako.

    That, too, is my question.
    Be the "server" local or remote, wouldn't JSPs still
    be the easier solution? No. it will not. because you need a server. Server for a stand alone application is not esier. according to who said JSPs are easy?
    Its very very difficult.
    >
    When answering, please clarify. I'm a bit of a newbie
    here. :)To get sence about how hard is JSP, check Struts. this is very good open source Framework to simplify the JSPs. but it still complecated enough.
    or Tapestry my lovely open srouce Framework.
    its easier than Struts. but sill complecated because of the documentation.
    All in all, using JSP is the purpose of Java in the internet. but not for me. My application will not be available in the internet, i.e. no server, i.e. no need for JSP.
    i hope that helps a little.

  • Bat files from java application..its urgent pls help me

    hi
    My java application tries to execute the bat file, the code followes
    Runtime runs = Runtime.getRuntime();
              runs.exec("e:/customisation/test.bat");
    The bat file contains commands to copy files from one folder to another
    and some dos commands, but the commands are not executing. If i tried the bat file with some exe's like notepad its working well, but not working with dos commands.
    thanks in advance
    nisam

    Hi
    Your batch file will be working actually. But no output will be seen in the console window.
    For example I had created a batch file with the folowing code
    echo This is test
    copy test.bat test1.bat
    pause
    Even though I can't see the messages in the console, it executed when called using
    Runtime runs = Runtime.getRuntime();
    runs.exec("hi.bat");
    where hi.bat contains the above code.
    If you want to see the output messages also in the console, you have to redirect the outputstream to the current console. One such class this does is available somewhere in Java(I don't exactly remember :-( ). I think it is StreamPluginThread.java
    Regards

  • Running .bat files from java applications

    Has anyone tried to run a .bat file from a java application?
    I know I can run java commands by getting the application's runtime, but I've a number of *.bat files I like to run from the application without having to extract the commands from the .bat files.
    thks,

    Crikey! You were answered very shortly after you posted your question, and you STILL haven't bothered to come back. And are you going to create a new userid the next time you ask a question, since bat2004 seems tied to this particular question?

  • How to print PDF file from java application?

    Hi,
    I have a java application that needs to print an PDF files. Could any one provide me links to tutorial/sample codes for doing this?

    http://onesearch.sun.com/search/onesearch/index.jsp?qt=print+pdf+files&subCat=&site=dev&qp=&chooseCat=javaall&col=developer-forums

  • Can i open a flase file from java application?

    i want that when the user click a button on my java application,
    a flash file i made (Not html)will be showen .

    is it an executable(*.exe?), if it is then you could try using runtime.exec() to run it, but it would not be in a window that you created

  • A ques about Reading and Writing non-Latin character Strings

    Never had any need to to the captioned before, so I never investigated it. But now I do.
    We are in the midst of a major conversion of our software to UTF-8. Oracle Forms displays these Strings (ex: Українська) properly, but when I query the DB column behind the form and display the O/P to a TextArea, or use BufferedWriter to write it to a File it displays the old upside-down question mark. Similarly if I load data into the column, while it displays fine in my SQL statement, it loads wrong and displays on the form as UD?marks. So, what simple thing am I missing?
    ~Bill
    Edited by: abillconsl on Dec 5, 2008 8:31 PM

    I downloaded the ojdbc14.jar and the pgm can find it and I can connect to the DB via:URL url = "jdbc:oracle:thin:"+host; // host is the hostname, port and sid
    Connection con = DriverManager.getConnection( url, uid, pwd );
    {code}
    But I want to connect via:
    {code:java}"jdbc:odbc:"+sid; // where sid is the USER DSN in the ODBC Data Source Administrator
    {code} ... but I need to run the setup pgm for the driver and I can't find one for Oracle. Anybody know where I should be looking? In the past the DB Admins set these up.
    ~Bill                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • What the best way to create XML files from JAVA application?

    Hi to all,
    I need to edit and to create new filex in format of xml. I know to parse, but what would be the best way to do:
    1. - Create new file, create like simle text file, or there is some clases that know to do it in more simple way
    2.a - Edit XML file, to take some data and add it to the XML in the place I want to.
    2.b - Also Edit, but not to add fields, just update some of them.
    Code examples or links to samples woul be welcomed.
    Best regards, Nick.

    I have tried working with XML directly using the Java classes but this was a pain. I then looked at DOM4J and JDOM and found JDOM easier to use.

  • Opening files from java application by other programs

    Hi! Could you tell me how to solve such task. After saving of file on local drive by applet i need to show a link "View file" that will open file by assotiated programs (.doc - MSWord, .pdf - Acrobat Reader etc. applet will work on Linux platform too). Thanks!

    Just provide a link to the file and leave it up to the OS to determine which program to use to open it.

  • Non-Latin Character Display On Web Page

    In a Java web application, only one non-Latin character display issue is that when they are typied into a JSP file. Otherwise, non-Latin characters display correctly from the message property file or from database.
    Anyone know how to solve it?
    Thanks.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Solved!
    Just need to have the JSP page tag on the related JSP file.
    null

    Welcome to our community, Denise
    Perhaps check the names of all the files involved? What type
    of web server are you using?
    You say that your co-worker said she is linking to the skin
    file from a .htm page, but what is missing here is whether she is
    using the .HTM page you provided in the mix or if it's one she
    created herself. If it's one she created herself, that may be the
    issue.
    Cheers... Rick

  • Application to read 2 log files from internet

    Hi,
    Anybody could tell me how to develop this project. I'm lack of time. thanks
    You have been asked into a company called Broken Arrow Software as a Senior Software Engineer and Management consultant. You are being paid very handsomely and have been asked to write an application program in Java for parsing a log file.
    � The program will have a standard menu using the AWT only.
    � ALL LAYOUTS MUST USE ONLY THE BORDER-LAYOUT OR GRID-LAYOUT OR A COMBINATION OF BOTH (Any other layouts score zero).
    This application reads two Log files from the internet. The first file contains USA state names and the abbreviation used for that state. This information will be used in displaying totals from another network file and should be stored in an array (or two arrays, or a two dimensional array) in the program. The second file should extract the �Reversed subdomain� section from a Log file (a section is shown later) and store this in an array in the application. This should be processed and only those domains beginning with �us.� should be processed. Each �us.� Has an abbreviated USA state after it (�tx� is an abbreviation for Texas). The abbreviations are sorted and all states are on consecutive lines and each displays a number of accesses for that state. The accesses should be totalled and displayed in the current Frame for each state in the form of Java List components (these do not need to be synchronised so that they all scroll in unison).
    The application will be a Java application with the following menus and MenuItems:
    � Splash screen (10%)
    � Application (20%)
    o Open USA abbreviation file
    o Clear screen
    o Exit
    � File (25%)
    o Open network log file
    o Open locally saved report file
    o Recent report files
    o Save as report file
    � Graph (20%)
    o Plot
    � Help (15%)
    o Help on Application
    o About
    A basic pass for the application will be for a basic implementation of an application with �help� options and some basic implementations of a Splash screen and some basic file and application options. Very high marks will be awarded for processing network files, saving and opening files, very good HCI, application design and error handling, excellent OO design for classes, gorgeous layout and commenting of code and excellent graphing capabilities.
    Error handling dialogs and overall application design (10%)
    Every class must be in a separate file.
    Inheritance should be used for WindowListeners of Frames and Dialogs.
    Up to 10% can also be lost by unprofessional code layout and lack of professional standards. Always adhere to standards taught throughout the module and your time at the University of Northumbria.
    Examples of non-professionalism would include bad indentation, no comments, meaningless variable names, politically incorrect graphics, commented out code, empty .java files, .java files which are not part of the project etc. Remember your application is your livelihood and your company depends on your application standards.
    The splash screen must be a Frame with a Canvas as part of it showing your own logo. Your logo should be individual to you but does not need to win the computing equivalent of the Turner prize. The application should be displayed behind the Splash screen and both should be visible. The application must not be able to be brought to the front and used without the Splash screen being disposed of.
    The application should only enable the �Open USA abbreviation file�, �Open locally saved report file�, �Help� options and �Exit� Menus and MenuItems, when the application starts. On opening a valid USA abbreviation file, then the other Menus and MenuItems should be enabled.
    The abbreviations should be read into an array. These should be used in displaying the totals for the reversed subdomain totals for each USA state. A total for all USA states should be displayed at the bottom of the current Frame, with a suitable Label (this design is your own). This current Frame should display a series of Lists starting with a List of USA state number (1 to n). A List of USA state abbreviation should be next followed by a List of the actual USA state name, followed by a List of the total accesses for that state.
    The report file should be an ASCII file that can be printed out from an ASCII text editor such as DOS edit or Microsoft NotePad.
    The �Open� network files should display a Dialog asking for the http:// address of the file, with �OK� and �Cancel� options. It is helpful if the user can hit �return� instead of clicking on �OK� and �Escape� instead of �cancel�. Error Dialogs should be used to indicate any errors that may occur and the state of the application should be reset to that of before displaying the Dialog.
    When �Save as report file� is chosen a FileDialog box should be used for the user to choose both directory and filename. The file should be able to be saved as a �.rpt� file.
    Open report file should display the report in a Frame; the design of which is your own.
    Plotting the graph should pass a two dimensional array to a Frame with a Canvas. The Canvas should have a Paint method that draws the axis for the graph and any suitable Headings etc. The graph should draw a histogram of totals per USA states. The graph design is your own but you may wish to use Microsoft Excel as a good example of drawing a histogram.
    The �Clear screen� option should clear any data off the current screen.
    The �Exit� option should quit the application but it may be helpful to ask the user if they really want to exit the application.
    Help must be Java code and not linking into HTML. It should display help in a well designed screen. The most basic implementation might use a scrollable TextArea for a basic mark.
    See other software for a good �About� screen. The most basic should display your name, date, version and company.
    � Help should display your help on using the application. As a senior software engineer, the design is your own, based on experience of using applications, as is the opening splash screen. You may use other applications for inspiration only, as these will make up your experience.
    � Your good knowledge gained from HCI units studied should prove invaluable in the interface design and the usability of the application.
    � The design (Screens and classes) and quality and documentation of code throughout the application will be marked. The experience gained from programming 1 and 2 and Object Oriented Programming should prove invaluable throughout the application, as should any GUI units studied.
    The log file can be accessed at:
    http://computing.unn.ac.uk/staff/cgpb2/public_html/log.html

    You would really gain ever so much more from this exercise if you would write a couple of classes, then come back with some specific questions. If you're completely lost, try starting with the GUI first. It's not the best practice, always, but it is easy to visualize.
    On a side note, I wish I'd had assignments even half this intersting when I was in my Java classes...

Maybe you are looking for