Is it possible to get file encoding?

I am working with windows netsh util
/**filename = path to file*/
private static BufferedReader readFileWithBufferedReader(String filename){
        FileInputStream fis = null;
        InputStreamReader sr= null;
        BufferedReader r    = null;
        try {
            fis = new FileInputStream(filename);
        } catch (FileNotFoundException ex) {
            ex.printStackTrace();
        }//fis catch
        try {
            /*creating InputStreamReader with encoding param*/
            sr = new InputStreamReader(fis, "Cp866" /*"Cp1251"*/);
            System.out.println("encoding ::: " +sr.getEncoding());
        } catch (UnsupportedEncodingException ex) {
            ex.printStackTrace();
        }//sr catch
            /*wrapping to BufferedReader*/
            br = new BufferedReader( sr);
        System.out.println("YES!!!");   
        return br;
    }I get InputStream from console. I set encoding as "cp866" (it's O.K.)
Then, I save stream to file.
Then user can open this file and get config from file.
The problem is in open file procedure.
I do not know file encoding: it can be "cp1251" (windows cyrillic) or it can be "cp866" (cmd output).
So if user tries to open "cp1251" file with "cp866" encoding, he gets unreadable characters.
Is it possible to get file encoding and then re-create InputStreamReader with proper encoding?

Well, you can't get the file encoding. It's not saved with the file. Unless it's your file format, in which case you can save whatever you want.
There are apps that can guess a file's encoding.
Of course, if you have control over the files entirely, it shouldn't be a problem, and generally it'd make life a lot easier to just use UTF-8.
So if user tries to open "cp1251" file with "cp866" encoding,
he gets unreadable characters.what if you read a "cp866" with "cp1251" encoding?

Similar Messages

  • How to get file encoding type

    Hi ,
    How to get the file encoding type,
    for example file is saved with the .txt and encoding is utf-8 and another file is saved .txt with encoding is ascii,
    actually before reading the file i want idetify the encoding type
    please help me it is very urgent for me..
    thanks in advance

    As there is no established regime for signing most encoding types, the only way to do this is to start parsing the file in one encoding, see if you get something that makes sense, and if not try another encoding, and so on. I.e. you have to code it yourself and even then it is not usually reliable. Sorry.
    Drake

  • Hard-drive Crash!! - Possible to get files from Apple TV to my new hdd?

    My hard-drive just crashed and I just received the new hard-drive. I was wondering if there is a possiblity to restore into my new hard-drive the files I had downloaded from my old hard-drive to my apple TV. I have a alot of music, photos etc on my apple tv hard-drive, I hope there is a way to restore the files back to my new hard-drive.
    Thank you.

    there is no easy way... people need to realize that appleTV is not a backup drive and with all the valuable, irreplaceable things on your computer you need to have a backup strategy... can you really afford to lose everything on your computer? don't buy one hard drive, buy two... one to replace the dead one and one for a backup drive or buy a hard drive and a time capsule (with time capsule you can do wireless backups from your macbook).
    getting the files off would involve breaking your warrantee...
    1) taking the appleTV apart (not an easy task, but you can find instructions online), removing the hard drive, hooking it up to your computer... by putting it into a USB enclosure or eSATA or internally
    2) hacking your appleTV (instructions online) SSHing to it and getting the files off that way...

  • Jinitiator 1.3.1.2.6 on win 7 64 and win xp (different file.encoding)

    Hello,
    our customer has moved from windows XP to Windows 7 and he uses Jinitiator 1.3.1.2.6...
    In some "Forms" I have implemented a PJC to save datas from clob to local file system..
    But there is a problem....
    If I run the same application with Windows XP I get file.encoding=Cp1250 which is ok....
    If I run the same application with Windows 7 (64) I get file.encoding=CP1252 and here is the problem...
    Is there any way to run Jinitiator (or set up file.encoding to/with) Cp1250?
    Maybe is this a local problem with windows?
    thank you..

    First, I will start by saying that JInitiator was not intended to run on Win7, especially 64bit. So, it may be time to think about moving to the Java Plugin. Preferably one which is certified with your Forms version.
    To your issue, I suspect you need to change the "Region and Language" settings on the client machine. This can be found on the Control Panel. If that doesn't help, take a look at this:
    http://stackoverflow.com/questions/4850557/convert-string-from-codepage-1252-to-1250

  • I've recently been given a macbook pro from uni, with lots of adobe software on. I want to pair it with my iMac which has music etc and is it possible to get the software to the imac and the files to the macbook?Giving me the best of both :-)

    I've recently been given a macbook pro from uni, with lots of adobe software on. I want to pair it with my iMac which has music etc and is it possible to get the software to the imac and the files to the macbook?Giving me the best of both :-)

    You would need the original installation disks or files for the Adobe software to get it onto your iMac, and having it on two computers may not be allowed by your university's licensing. Talk to whoever issued the MacBook.
    As to the music, just copy it over to the MacBook, either via Home Sharing, file sharing, or an external storage medium (hard drive, USB flash drive, etc.).
    Regards.

  • Is it possible to get the style, font and related info of a paragraph of a in design file and write it on the same in design file  on the  left side

    Is it possible to get the style, font and related info of a paragraph text  of a in design file and write  all the stuff on the same in design file  on the  left side with small fonts 
    as
    Lets  this is a text in in design file    :
    style : abc                      we are going to check the  condition  Agence Wallonne pour la Promotion d'une Agricultur we are going to check the  condition  Agence Wallonne pour la    font 12                                  d'une Agricultu we are going to check the  condition  Agence Wallonne pour la Promotion d'une Agricultu
    style : xyz                      we are going to check the  condition  Agence Wallonne pour la Promotion d'une Agricultur we are going to check the  condition  Agence Wallonne pour la    font 10                                  d'une Agricultu we are going to check the  condition  Agence Wallonne pour la Promotion d'une Agricultu

    Hi Poojith
    Not sure if this would solve your requirment but just in case might be helpful:
    1. We can mix up the HTML and HTMLB components in the JSP Page. However, can access only the HTMLB components in the controller. The following link refers to what customizations are offered by the HTMLB framework:
    [http://www.sapdesignguild.org/resources/htmlb_guidance/]
    2. Another option would be to use AbstractPortalComponents or a simple web app if that's feasible. (where custom UI themes, css and layout are more in control of the developers.)
    Thanks
    Deepak

  • How to get the "encoding" of a XML file using JDOM

    As in XML file, <?xml version="1.0" encoding="UTF-8" ?> indicates the encoding of this file
    while using JDOM to parse a XML file, how can I get the encoding type?
    thanx!!!

    What my program do is to get the encoding of XML files and convert them to UTF-8 encoding files, while I need this "encoding" information of the original XML document thus I can convert...
    After reading specifications and JDOM docs, the truth turns to be disappointed, no function is provided to get this information in JDOM level 2(the current released one), while it's promissed that this function will be provided in JDOM level API....
    Thanx all for your help and attention!!!

  • How to get the encoding of a XML file ...

    Hi,
    How do you get the encoding of a XML file?
    For example,
    <?xml version="1.0" encoding="SJIS"?>
    I am trying to retrieve the above encoding="SJIS", but I can't seem to locate the API for doing so.
    Thanks in advance for any help,
    Eric

    Hi ddossot,
    Thanks for your suggestion.
    However, the xerces.jar file that comes with my old tomcat server is an old version and thus, the getEncoding method is not even present in the DocumentImpl class. The option to update to a newer version of tomcat and xerces is not available. What a pity... :-(
    Well, I just have to try to find a way around. Worst case scenario, parse the first line in the xml file myself.
    Regards,
    Eric

  • Data recovery, possible to get the file structure back as well?

    Hi Apple Smarties,
    I closed my laptop lid on my external LaCie drive without ejecting the drive first (smart one!). After that the external drive wouldn't mount. I've used Data Rescue 3 to recover all the files from the drive... however it's just lumping all the files into one big batch :-( ...anybody know if it's possible to get the files into the correct files structure they were at before the drive got corrupted?
    Assistance would be HUGELY appreciated.
    Many thanks
    Kind regards
    Doug

    Thank you Barry. Yes, Comcast is my mail provider. It is a POP account.
    Now, if you could point me in the right direction to do that re-build, I would be ever so grateful. I did use the "rebuild" button on the Mail tool bar for that box and it did not help. Perhaps there is something else I could do?
    As I mentioned, I am very new to the Mac world, and I get a little lost. Well, at age 73, I guess that's not hard to do! Been on Windows forever so lots of the terminology in Apple is quite different for me.
    Message was edited by: JanJones

  • Is it possible to change the default file encoding?

    I have just learned that the "file.encoding" system property should be treated as read-only.
    (http://developer.java.sun.com/developer/bugParade/bugs/4163515.html)
    I am using this property to tell javac that the command arguments file has some other encoding than the system deafult, like this:
    javac -J-Dfile.encoding=UTF-8 @files-to-compile.lst
    On windows xp with us english locale it worked for all the SDK releases I checked, but for Windows 2000 Japanese Edition only one of the J2SDK 1.4.1 releases worked.
    My question is: is there an acceptable way to tell the JVM what the default encoding is? Or inform javac about the encoding of the argument file?
    The reason for having a UTF-8 encoded javac argument list file is that our application generates Java source files that can have unicode characters in their names. Seemingly Windows supports unicode file names so I did not want to restrict file names to those supported by the system encoding.

    Use javac's "-encoding" option.
    $ javac 
    Usage: javac <options> <source files>
    where possible options include:
      -g                        Generate all debugging info
      -g:none                   Generate no debugging info
      -g:{lines,vars,source}    Generate only some debugging info
      -nowarn                   Generate no warnings
      -verbose                  Output messages about what the compiler is doing
      -deprecation              Output source locations where deprecated APIs are used
      -classpath <path>         Specify where to find user class files
      -sourcepath <path>        Specify where to find input source files
      -bootclasspath <path>     Override location of bootstrap class files
      -extdirs <dirs>           Override location of installed extensions
      -d <directory>            Specify where to place generated class files
      -encoding <encoding>      Specify character encoding used by source files
      -source <release>         Provide source compatibility with specified release
      -target <release>         Generate class files for specific VM version
      -help                     Print a synopsis of standard options

  • Is it possible to get control of the .SWF files in JSP files

    Hi All
    In my web application, I got 4 swf buttons which are created by flash and they are embedded in the jsp's. Each button perform the navigation to other page.
    this is the jsp file.
         <table width="100%" border="0">
                  <tr>
                    <td width="2%" height="26"> </td>
                    <td width="31%"> <object classid="clsid:...." codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="22">
                        <param name="BASE" value=".">
                        <param name="BGCOLOR" value="">
                        <param name="movie" value="button1.swf">
                        <param name="quality" value="high">
                        <embed src="button1.swf" width="100" height="22" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" base="." ></embed>
                      </object> <font size="-1" face="Arial, Helvetica, sans-serif"> </font></td>
                    <td width="67%" class="sitemapgy">*Add*  </td>
                  </tr>
                  <tr>
                    <td height="26"> </td>
                    <td><object classid="clsid:..." codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="22">
                        <param name="BASE" value=".">
                        <param name="BGCOLOR" value="">
                        <param name="movie" value="button2.swf">
                        <param name="quality" value="high">
                        <embed src="button2.swf" width="100" height="22" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" base="." ></embed>
                      </object> </td>
                    <td class="sitemapgy">*Edit* ;</td>
                  </tr>
                  <tr>
                    <td height="26"> </td>
                    <td><object classid="clsid:..." codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="22">
                        <param name="movie" value="button13.swf">
                        <param name="quality" value="high">
                        <param name="base" value=".">
                        <embed src="button7.swf" base="."  quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="100" height="22" ></embed>
                      </object></td>
                    <td class="sitemapgy">*Create*</td>
                  </tr>
                  <tr>
                    <td height="26"> </td>
                    <td><object classid="clsid:.." codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="22">
                        <param name="BGCOLOR" value="">
                        <param name="movie" value="main_print.swf">
                        <param name="quality" value="high">
                        <param name="base" value=".">
                        <embed src="main_print.swf" base="."  quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="100" height="22" ></embed>
                      </object></td>
                    <td class="sitemapgy"><font face="Arial, Helvetica, sans-serif">*Print*</font></td>
                  </tr>
                  <tr>
                    <td height="26"> </td>
                    <td><object classid="clsid:..." codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="100" height="22" >
                        <param name="BGCOLOR" value="">
                        <param name="BASE" value=".">
                        <param name="movie" value="button3.swf">
                        <param name="quality" value="high">
                        <embed src="button3.swf" width="100" height="22" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" base="." ></embed>
                      </object></td>
                    <td class="sitemapgy"><font face="Arial, Helvetica, sans-serif">*_Admin_*</font></td>
                  </tr>
                  <tr>
                    <td height="24"> </td>
                    <td> </td>
                    <td> </td>
                  </tr>
                </table>When I click the button3.swf (Admin) button....it navigates to other page...Before that I need to get control of swf button and need to perform some login checks.
    Is it possible to get control?
    Thanks

    Thanks for your responses, I tried in the same way but when ever it looking at the path "/admin/admin_main.jsp",
    its navigating to error page if the username is admin too(abcd).
    Can you please help me regarding this.
    I am sending you my code and web.xml.
                     <filter>
              <filter-name>ExampleFilter</filter-name>
              <filter-class>com.pack.db.ExampleFilter</filter-class>
         </filter>
                   <filter-mapping>
              <filter-name>ExampleFilter</filter-name>
              <url-pattern>/admin/admin_main.jsp</url-pattern>
         </filter-mapping>
    import java.io.*;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.RequestDispatcher;
    import javax.servlet.http.*;
    public class ExampleFilter implements Filter {
         private FilterConfig filterConfig=null;
         public void init(FilterConfig config) throws ServletException {
              this.filterConfig = config;
         public void destroy() {
              filterConfig = null;
         public void doFilter(ServletRequest request, ServletResponse response,
                   FilterChain chain) throws IOException, ServletException {
              RequestDispatcher rd = null;
              String userInfo = "";
              String userName="";
              if (request instanceof HttpServletRequest) {
                   userInfo = ((HttpServletRequest) request).getUserPrincipal()
                                      .getName();
                             String[] pieces = userInfo.split("\\\\"); // Firefox sends DOMAIN\USERNAME as UserPrincipal
                                  userName = pieces[pieces.length -1]; // getting the username for which I need to perform check
                                  if(userName!="abcd"){
                                  System.out.println("userName IN ELSE PART:"+userName);
                                  System.out.println("INVALID USER NAME");
                                 rd = request.getRequestDispatcher("/admin/error.html");// i need to forward the response url to error page if the username is not equal to "abcd"
                                 rd.forward(request, response);
                             else{
                             chain.doFilter(request, response); // if username="abcd" I need to navigate to normal pages.
    Thanks

  • Is it possible to get a count of all the class files in a Flash Builder project?

    Is it possible to get a count of all the class files in a Flash Builder project?
    Thanks!

    Resultsets are one per connection unless you have copied them. Do you have lots of connections are you properly reusing them or at least closing and discarding all references?
    See tutorial and Javadoc of API too

  • Is that possible to get data from the red trace in this BMP file

    I have an instrument, which only export image file. I want use labview to replot it and do some analysis. The image file is like attachment. Is that possible to get data from the red  trace in this BMP file via labview vis?
    Attachments:
    coax312.bmp ‏4741 KB

    I looks to me that 515 pixels represents 200 meters, so multiply the
    x-values by 0.3885 meters/pixel to get the true x-values.  I don't
    have enough information to scale the y-axis.
    Randall Pursley
    Attachments:
    Compute from BMP.vi ‏66 KB

  • My MacBook Pro came with Lion pre-installed so I can't re-download it from the app store. Is it possible to get the installESD.dmg file and how can I get it if I can't re-download Lion in Apple Store option?

    My MacBook Pro came with Lion pre-installed so I can't re-download it from the app store. Is it possible to get the installESD.dmg file and how can I get it if I can't re-download Lion in Apple Store option?

    FYI Mac OS X is not designed to be installed on additional Macs, unless you purchased it from the App Store, in which case you can make as many copies as you wish and install it on as many Macs as you own.
    From the Recovery Disk Assistant -
    Notes
    If the computer shipped with OS X Lion or Mountain Lion, the external recovery drive may only be used with the system that created it.
    If the system was upgraded to Lion or Mountain Lion purchased from the App Store, the external recovery drive can be used with other similarly-upgraded systems.

  • Is it possible to delete files from time machine?

    Is it possible to delete files from time machine? I had a drive crash, restored the files to a new drive, and now the old versions and the new versions of the files are both backed up, taking up a mountain of drive space. Do I just have to wait 'til the drive gets full and then tell it what to delete first?

    Hi, I need help in a related problem. I have 500gb time capsule. I needed larger hard drive, so I now use TM to back up to a different 1tb hard drive. So I don't need the TC as a TM back up device. But I want to use the TC's hard drive as an extra external hard drive. I deleted the files that were on it. but it still shows it has a sparsebundle file with a size of over 400gb ( probably the size of the old backups). When I use disk utility to try to erase it, I am not offered the erase tab. This "disk" does show on the desk top as a mounted disk (I think) with only 53 gb free. How can I set this up so all the disk space is free and I can use it for storing files, not as a back up? Thanks

Maybe you are looking for

  • HP LaserJet Pro CM1415fnw Color Multifunction Printer - CAN'T FIND ANY WIRELESS NETWORKS

    PRINTER: HP LaserJet Pro CM1415fnw Color Multifunction Printer OS: Windows 7 OWNED: Over 2 years with no problems LOCATION/SET-UP: At my personal residence. All-in-one wireless router through cable company. ISSUE: All of a sudden, printer cannot find

  • Process flow Activity File Exists

    Hi Software: warehouse builder 11.1.0.7 OS: Redhat 5.5 DB: 11gR1 I am trying to use the activity "File Exist" on a process flow to know if a file does exist, with two transitions one with condition "EXISTS" that ends in success and one with the condi

  • Duplicate records in DTP

    Guys, My DTP failed 4 days back, but the full load from Source system to PSA is executing successfully. To correct the DTP load, I have deleted the last DTP request and also all the PSA requests except the last one and when I re-executed the DTP I am

  • Getting rid of AdobeResourceSynchronizer (CS3) in Login Items OS 10.4.11

    I'd like to know how to get rid of the Acrobat (CS3) AdobeResourceSynchronizer from Login Items on Mac OS 10.4.11. Reportedly, it replaces itself in Login Items if removed. In trying to follow the instructions from the Barnaby James blog of 12/06 (fi

  • Server 2008 SP2 DPI settings

    We are running a Windows 2008 Standard SP2 32-bit terminal server. One of the users would like to have the option to change the DPI settings under their session. I found a MS hotfix, but it does not apply to this version (http://support.microsoft.com