How to identify binary vs ASCII file???

Hello,
What is the best way to decide whether a file is binary or plain text?
Thanks in advance.
Chris.

Other than passing through the bytes, check that there are no bytes that you wouldn't usually have in a text file and pray that the file isn't in an "exotic" character encoding such as utf8?
There is no real difference. Both "binary" and "text" files contain bytes.

Similar Messages

  • How Do I Comile an Ascii File?

    My application needs to generate, compile, and load a class.
    java.lang.Compiler is not the answer.
    What is? How do I convert a String or ascii file into a Class object?

    You would have to use com.sun.tools.javac.Main. However, this is one of the non-documented and non-supported classes. Furtermore, it exists only in the JDK and not in the JRE.
    You might be able to distribute the tools.jar from the lib directory in the JDK with your application. But I am not sure that you are actually allowed to do that. There may be some license issues.

  • How to convert tdms to ascii files?

    Hello,
    I need to convert *.tdms files to an ascii file.  I have 16 channels and scalling coefficient information in the tdms file, With the TDMS-Image Viewer i can see the 1-D array waveform perfectly, but I cant write it to an ascii file. When I use a signalexpress.vi or the spreetsheat.vi for writing an LVM/ascii file,  information gets lost. (Red symbol at INPUT!!!!)
    Please answer me, because I dont have lots of experience with labview and an ascii file is more easier to handle for me! I found only export to matlab and exel, but i just want it in an ascii file.  Reading the tdms and opening it is no problem, but connecting the right blocks to the 1D array waveform without dataloss doesnt work.
    thank you for reading
    danny

    Thank you for reply,
    i have the new version 8.5.   With signalexpress.vis  i can do asciis but the red symbol (at input) is there so i dont want to get information lost.
    The tdms file has header information for scalling factors and unscalled data for 16 channels.
    so because tdms files are faster for writing i want to convert them to ascii with a Convertion Vi, but it seems that with an express vi he stops because it cant handle handle with the headerinformation.
    now i use the signalexess vi to write tdms data, before i did it manully by setting channel and group information.
    Please tell me if the red symbol AT input of a Signalexpress VI does matter?   its a 1D array wavefrom that goes in to the input.
    thank you for this discussion, i hope that i dont need to use the matlab import option for tdms!!
    greetings danny

  • How to handling Binary data and File operation?

    Hello Everyone,
    I think this question might have been asked a lot of time but I was unable to find one solution so, please help needed in this from all you guys..
    I am creating a byte[] of the media files of mp4, and jpg, using the below code,,
    File ff = new File(filename);
            fos = new FileOutputStream(ff);
            int b;
            byte[] f = this.getMediaFile();
            for (b = 0; b < f.length; b++) {
                if (f[b] != -1) {
                    fos.write(f);
    fos.flush();
    fos.close();
    After i convert it i have to store it in the MySql Database as BLOB object, for retrieving byte[] from the database is simple i can do that also successfully with this code.java.sq.Blob obj = (java.sql.Blob) rs.getBlob("file");
    InputStream is = null;
    ByteArrayOutputStream bc = null;
    is = obj.getBinaryStream();
    bc = new ByteArrayOutputStream();
    int b;
    while ((b = is.read()) != -1) {
    System.out.print(b + " ");
    bc.write(b);
    Now the real problem is that when i want to recreate a mp4 audio or video file i am unable to do so, the file created is smaller in size and also it doesn't get played in windows default player nor VLC. I am able to get the image file of jpg format using the BufferedImage & ImageIO.writer();
    How do i do for mp4 file, have no clue for that.
    Pleases help out with this.
    Thanks..                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    if (f[b] != -1) {I don't get that line. What if you try to output the data without that condition, like this:
    fos = new FileOutputStream(ff);
            byte[] f = this.getMediaFile();
            for (int b = 0; b < f.length; b++) {
                 fos.write(f);
    fos.close();

  • How can I append sequential ascii files?

    I am trying to read ~100 sequential ascii files and then append them end-on-end into one text file. Is there a simple way to automate this step so I don't have to select each ascii file individually?

    You can use the list directory to get all the file names under that directly. Then programactically read contents of the file and save to single file by having append to file TRUE on the write VI.
    Naresh

  • How to print binary to a file?

    I am using oracle 8i.
    I am storing chinese character in varchar2(150) column while my character sets was AMERICAN_AMERICA.WE8ISO8859P1.
    Actually, it can be retrieved successfully in discoverer or sqlplus in I set the nls charset to AMERICAN_AMERICA.ZHT16BIG5. however, I cannot output the column correctly in a PL/SQL store pro. I am trying UTL_FILE to print but it is a failure.
    how can I print the character correctly? any function in PL/SQL convert the data to binary so that I can print the character without any charset transformation?
    thx.
    marvin

    Thank you for responding.
    I do know when the job start. The job always start with string as following (delima):
    StringBuffer bufStr = new StringBuffer();
    bufStr.append((char)0x1B);
    bufStr.append("%-12345X@PJL COMMENT");
    bufStr.append((char)0x0D);
    bufStr.append((char)0x0A);
    String delima = new String(bufStr);
    Therefore, how can I check the whole delima string while I just read byte per byte from the file?
    Thanks again.
    Henry

  • How to Identify whether my WMA file is DRM protected?

    A friend just loaded some audio files of our lecture class onto my computer that are .wma files from a usb drive recorder she owns. I downloaded one or two programs to try to convert them so I could play them on iTunes but the programs didn't work.
    I can play them on QuickTime but I would really like to be able to play them on my iPhone and format/organize them on my iTunes (since that is where all of my other audio files are).
    I'm worried they aren't converting correctly because they are DRM-protected, though I don't know why they would be! Can anyone tell me where to find out in the audio file if the file is DRM protected or not?

    I can play them on QuickTime
    They're not protected. Try using Switch or EasyWMA.
    (53249)

  • ASCII-File aus SAP Business One

    Hallo
    Ich muß eine Schnittstelle zu einer Verpackungsmaschine, die auch die Etiketten druckt bedienen. Den Satzaufbau für die Etiketten habe ich vom Hersteller bekommen und kann den auch soweit erstellen. Was mir fehlt ist die Übergabe einer ASCII-Datei an die Schnittstelle  (Ich vermute mal mit einer Printdefinition von Coresystems ?!) 
    Hat von Euch schon mal jemand so etwas gemacht ?
    Bin für jede Hilfe dankbar
    Viele Grüße an alle
    Annette Lenhard

    Here is my question in english
    Well, I have to create an interface to a machine that pack the goods and that print lables at the same time. This machine understands only ASCII-File. So my question is - How can I create an ASCII-File out of Business One?
    The structure of the sentence is clear but I don't know how to respond the maschine ?
    Kind regards
    Annette Lenhard

  • How to store binary files into ascii files

    I need to record Data with sampling rate of 100kHz and for that reason I saved this data as a .bin. In principle this file should consist of two rows, the time and the data (voltage) domain with an ?resolution? of 16 bit. For my analysis I need this files as an ASCII file. I´m an absolute rookie in Programming (and LabView as well) and so far unable to slove this problem...can anyone help me?

    Hola,
    I´m still waiting for the computer I have ordered for my setup, but anyway I have borrowed one...2 GB Ram and a 3.00 GHz Pentium 4, not the worst I guess.
     To acquire the data I´m using the PCIe 6251M Series DaqCard and a BNC 2120 Connector Block.
    Corresponding the example “Graph Acquired Binary Data”. Yes it is possible to display the saved data from the .bin file, but this does not help me to convert it into an txt (ascii) file.
    So far I´m unable to use the “array to spreadsheet string” function in a proper, working way...I think I have to lern more about the way it has to be programmed....
    Tituriel

  • How can i write also to xml file the settings of the Tag property to identify if it's "file" or "directory" ?

    The first thing i'm doing is to get from my ftp server all the ftp content information and i tag it so i can identify later if it's a file or a directory:
    private int total_dirs;
    private int searched_until_now_dirs;
    private int max_percentage;
    private TreeNode directories_real_time;
    private string SummaryText;
    private TreeNode CreateDirectoryNode(string path, string name , int recursive_levl )
    var directoryNode = new TreeNode(name);
    var directoryListing = GetDirectoryListing(path);
    var directories = directoryListing.Where(d => d.IsDirectory);
    var files = directoryListing.Where(d => !d.IsDirectory);
    total_dirs += directories.Count<FTPListDetail>();
    searched_until_now_dirs++;
    int percentage = 0;
    foreach (var dir in directories)
    directoryNode.Nodes.Add(CreateDirectoryNode(dir.FullPath, dir.Name, recursive_levl+1));
    if (recursive_levl == 1)
    TreeNode temp_tn = (TreeNode)directoryNode.Clone();
    this.BeginInvoke(new MethodInvoker( delegate
    UpdateList(temp_tn);
    percentage = (searched_until_now_dirs * 100) / total_dirs;
    if (percentage > max_percentage)
    SummaryText = String.Format("Searched dirs {0} / Total dirs {1}", searched_until_now_dirs, total_dirs);
    max_percentage = percentage;
    backgroundWorker1.ReportProgress(percentage, SummaryText);
    percentage = (searched_until_now_dirs * 100) / total_dirs;
    if (percentage > max_percentage)
    SummaryText = String.Format("Searched dirs {0} / Total dirs {1}", searched_until_now_dirs, total_dirs);
    max_percentage = percentage;
    backgroundWorker1.ReportProgress(percentage, SummaryText);
    foreach (var file in files)
    TreeNode file_tree_node = new TreeNode(file.Name);
    file_tree_node.Tag = "file";
    directoryNode.Nodes.Add(file_tree_node);
    numberOfFiles.Add(file.FullPath);
    return directoryNode;
    The line i'm using to Tag is:
    file_tree_node.Tag = "file";
    So i know what is "file" then i make a simple check if the Tag is not null then i know it's a "file" if it's null then it's directory.
    For example this is how i'm checking if it's file or directory after getting all the content from my ftp server:
    if (treeViewMS1.SelectedNode.Tag != null)
    string s = (string)treeViewMS1.SelectedNode.Tag;
    if (s == "file")
    file = false;
    DeleteFile(treeViewMS1.SelectedNode.FullPath, file);
    else
    RemoveDirectoriesRecursive(treeViewMS1.SelectedNode, treeViewMS1.SelectedNode.FullPath);
    I also update in real time when getting the content of the ftp server xml file on my hard disk with the treeView structure information so when i'm running the program each time it will load the treeView structure with all directories and files.
    This is the class of the xml file:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Xml;
    using System.Windows.Forms;
    namespace FTP_ProgressBar
    class TreeViewXmlPopulation
    // Xml tag for node, e.g. 'node' in case of <node></node>
    private const string XmlNodeTag = "node";
    // Xml attributes for node e.g. <node text="Asia" tag=""
    // imageindex="1"></node>
    private const string XmlNodeTextAtt = "text";
    private const string XmlNodeTagAtt = "tag";
    private const string XmlNodeImageIndexAtt = "imageindex";
    public static void DeserializeTreeView(TreeView treeView, string fileName)
    XmlTextReader reader = null;
    try
    // disabling re-drawing of treeview till all nodes are added
    treeView.BeginUpdate();
    reader = new XmlTextReader(fileName);
    TreeNode parentNode = null;
    while (reader.Read())
    if (reader.NodeType == XmlNodeType.Element)
    if (reader.Name == XmlNodeTag)
    TreeNode newNode = new TreeNode();
    bool isEmptyElement = reader.IsEmptyElement;
    // loading node attributes
    int attributeCount = reader.AttributeCount;
    if (attributeCount > 0)
    for (int i = 0; i < attributeCount; i++)
    reader.MoveToAttribute(i);
    SetAttributeValue(newNode,
    reader.Name, reader.Value);
    // add new node to Parent Node or TreeView
    if (parentNode != null)
    parentNode.Nodes.Add(newNode);
    else
    treeView.Nodes.Add(newNode);
    // making current node 'ParentNode' if its not empty
    if (!isEmptyElement)
    parentNode = newNode;
    // moving up to in TreeView if end tag is encountered
    else if (reader.NodeType == XmlNodeType.EndElement)
    if (reader.Name == XmlNodeTag)
    parentNode = parentNode.Parent;
    else if (reader.NodeType == XmlNodeType.XmlDeclaration)
    //Ignore Xml Declaration
    else if (reader.NodeType == XmlNodeType.None)
    return;
    else if (reader.NodeType == XmlNodeType.Text)
    parentNode.Nodes.Add(reader.Value);
    finally
    // enabling redrawing of treeview after all nodes are added
    treeView.EndUpdate();
    reader.Close();
    /// <span class="code-SummaryComment"><summary>
    /// Used by Deserialize method for setting properties of
    /// TreeNode from xml node attributes
    /// <span class="code-SummaryComment"></summary>
    private static void SetAttributeValue(TreeNode node,
    string propertyName, string value)
    if (propertyName == XmlNodeTextAtt)
    node.Text = value;
    else if (propertyName == XmlNodeImageIndexAtt)
    node.ImageIndex = int.Parse(value);
    else if (propertyName == XmlNodeTagAtt)
    node.Tag = value;
    public static void SerializeTreeView(TreeView treeView, string fileName)
    XmlTextWriter textWriter = new XmlTextWriter(fileName,
    System.Text.Encoding.ASCII);
    // writing the xml declaration tag
    textWriter.WriteStartDocument();
    //textWriter.WriteRaw("\r\n");
    // writing the main tag that encloses all node tags
    textWriter.WriteStartElement("TreeView");
    // save the nodes, recursive method
    SaveNodes(treeView.Nodes, textWriter);
    textWriter.WriteEndElement();
    textWriter.Close();
    private static void SaveNodes(TreeNodeCollection nodesCollection,
    XmlTextWriter textWriter)
    for (int i = 0; i < nodesCollection.Count; i++)
    TreeNode node = nodesCollection[i];
    textWriter.WriteStartElement(XmlNodeTag);
    textWriter.WriteAttributeString(XmlNodeTextAtt,
    node.Text);
    textWriter.WriteAttributeString(
    XmlNodeImageIndexAtt, node.ImageIndex.ToString());
    if (node.Tag != null)
    textWriter.WriteAttributeString(XmlNodeTagAtt,
    node.Tag.ToString());
    // add other node properties to serialize here
    if (node.Nodes.Count > 0)
    SaveNodes(node.Nodes, textWriter);
    textWriter.WriteEndElement();
    And this is how i'm using the class this method i'm calling it inside the CreateDirectoryNode and i'm updating the treeView in real time when getting the ftp content from the server i build the treeView structure in real time.
    DateTime last_update;
    private void UpdateList(TreeNode tn_rt)
    TimeSpan ts = DateTime.Now - last_update;
    if (ts.TotalMilliseconds > 200)
    last_update = DateTime.Now;
    treeViewMS1.BeginUpdate();
    treeViewMS1.Nodes.Clear();
    treeViewMS1.Nodes.Add(tn_rt);
    TreeViewXmlPopulation.SerializeTreeView(treeViewMS1, @"c:\XmlFile\Original.xml");
    ExpandToLevel(treeViewMS1.Nodes, 1);
    treeViewMS1.EndUpdate();
    And when i'm running the program again in the constructor i'm doing:
    if (File.Exists(@"c:\XmlFile\Original.xml"))
    TreeViewXmlPopulation.DeserializeTreeView(treeViewMS1, @"c:\XmlFile\Original.xml");
    My question is how can i update the xml file in real time like i'm doing now but also with the Tag property so next time i will run the program and will not get the content from the ftp i will know in the treeView what is file and what is directory.
    The problem is that now if i will run the program the Tag property is null. I must get the ftp content from the server each time.
    But i want that withoutout getting the ftp content from server to Tag each file as file in the treeView structure.
    So what i need is somehow where i;m Tagging "file" or maybe when updating the treeView also to add something to the xml file so when i will run the progrma again and read back the xml file it will also Tag the files in the treeView.

    Hi
    Chocolade1972,
    Your case related to Winform Data Controls, So i will move your thread to Windows Forms> Windows
    Forms Data Controls and Databinding  forum for better support.
    Best regards,
    Kristin
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to read a mixed text and binary random-access file?

    I have a PDF file which I want to decode. The format is a mixture of binary data and text. What I need is to position the file to a particular position, and then to read from that point as a stream either a set of binary bytes or straight ASCII text. I can't see how to do this (if in fact it's possible).
    I can open the file as a SeekableByteChannel and position it, but opening a stream repositions the file to the beginning - just what I don't want.
    Is there any way of opening a stream from part-way through a file?

    I think that I gave this topic a rather misleading title. What it really should be is "How to turn a random access file into a stream"?
    I realise that I can open an InputStream and skip the relevant number of characters - but this is highly inefficient on a large file where I will skipping about within the file. I need a stream so that I can apply other stream functions to it - buffering in memory will I suspect be too big.

  • Download ascii file procedure -problem as its getting binary after download

    Hi ,
    I have create a application that will download a file from a customised blob table by calling the procedure below which is as per oracle documentation:
    CREATE OR REPLACE PROCEDURE download_my_file(p_file IN NUMBER) AS
    v_mime VARCHAR2(48);
    v_length NUMBER;
    v_file_name VARCHAR2(400);
    Lob_loc BLOB;
    BEGIN
    SELECT b.MIME_TYPE, a.file_content, a.file_name,A.file_size
    INTO v_mime,lob_loc,v_file_name,v_length
    FROM PCD_PROCESS_TBL a,PCD_CNTL_TBL b
    WHERE a.seq_no =p_file AND ROWNUM<2;
    -- set up HTTP header
    -- use an NVL around the mime type and
    -- if it is a null set it to application/octect
    -- application/octect may launch a download window from windows
    owa_util.mime_header( NVL(v_mime,'text/plain'), FALSE,'ISO-8859-4' );
    -- set the size so the browser knows how much to download
    htp.p('Content-length: ' || v_length);
    -- the filename will be used by the browser if the users does a save as
    htp.p('Content-Disposition: attachment; filename="'||SUBSTR(v_file_name,INSTR(v_file_name,'/')+1)|| '"');
    -- close the headers
    owa_util.http_header_close;
    -- download the BLOB
    wpg_docload.download_file( Lob_loc );
    END download_my_file;
    The problem is that when our process updating the blob table with .dat file from Unix the data getting inserted fine.The file is basically a ascii file. But after downloading this by mime 'text/plain' or 'application/octet' i can see its getting as a binary file and it is not carriage return by a new line.A space like character getting inserted inside each line .
    can anybody please help out of that how can we get rid of this.
    I even change the blob to clob but still the problem persists even for clob the procedure not getting called.
    Thanks in advance,
    Deba

    Sounds like the problem you're having is the mismatch between the Unix text file format and the Windows text file format.
    Specifically, Unix uses LF (line feed) to denote the end of a line, while Windows uses CRLF (two characters, carriage return and line feed).
    If you open the file in Wordpad, you should see it ok.

  • How to Convert Binary Data in Binary File

    hi,
    my telecom client puts a binary file which is asn.1 encoded with BER.
    how to handle binary data in java.
    how to convert binary to hexa to ascii format
    how to convert binary to octet to ascii format
    please help me in this.
    regards,
    s.mohamed asif

    You don't need to convert the data.
    Only you can do is print it in that formats, like it:
    public static String byteArrayToHex(byte[] b) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < b.length; i++)
             sb.append(Integer.toHexString(b&255) + " ");
    return sb.toString();
    take a look at this
    http://java.sun.com/docs/books/tutorial/essential/io/

  • How do I find bad music files?  I have thousands of files, but some are bad.  When I try to load them into iTunes, it just spins.  I need a routine to identify and remove the bad files.  Any ideas?

    How do I find bad music files?  I have thousands of files, but some are bad.  When I try to load them into iTunes, it just spins.  I need a routine to identify and remove the bad files.  Any ideas?

    Hi ajoddo20,
    Welcome to the Apple Support Communities!
    You can use Home Sharing to import music and other media from one computer to another. Please use the instructions and information located in the attached article for information on how to complete the process. 
    iTunes 11 for Mac: Use Home Sharing to import items from another iTunes library
    Cheers,
    Joe 

  • How can I extract a dates column from an ascii file

    I am extracting data from an ascii file and the rest of the data is extracted using read from spreadsheet, but the date appears as just the day e.g. 22 for 22nd, how can I get the date, format in ascii is e.g 22/04/2006, can I do this by specifying something at format of read from spreadsheet ? Cheers
    Emily

    Hi,
    I found the other day that there are instructions included inside the Read From Spreadsheet vi on how to modify it slightly to read strings rather than doubles.
    If you drop the Read From Spreadsheet  vi onto the block diagram and double click on it, you will open the front panel for the vi. If you then select the block diagram (for Read From Spreadsheet) you will see an 'instructions' frame below the main 'code', and the 3rd paragraph tells you how to modify the VI to read the spreadsheet as a set of strings rather then doubles. Save the vi as a new filename when you've edited it or you will overwrite the existing vi!
    Using the newly modified vi you can read in your entire spreadsheet, extract the dates as strings, then do any conversion necessary to the other columns of the sheet to change them into the types of value you require (eg doubles).
    I hope this helps.
    Mark
    Applications Engineer
    National Instruments

Maybe you are looking for

  • Complete system lockup

    Hi all, Having an intermittent issue with my Laptop (It's a dell D630) I've had Arch running on it for about a week now and just today i've been getting random system crashed. The mouse/keyboard will completely freeze and if audio is playing it will

  • Edge 420 does not load operating system (Windows 7)

    My edge 420 suddenly stopped working yesterday. When I turn it on, it shows me option if I want to restore or use the normal set up, and neither of the options owrk, it just freezes no matter what key I press, F11 for recovery or Esq for normal set u

  • Quick time won't play mp4 rendered in After Effects.

    Since I upgrade to Mavericks i've been unable to play mp4 videos rendered using After Effects cs5. After rendering i get a file icon with the quicktime logo instead if the usual thumbnail with the play button; first indication that the clip might not

  • I need to covert the following MS SQL query to Oracle.

    The query is as follows.. SELECT B.AL_DESCRIPTION,Count(C.TC_STATUS) FROM ALL_LISTS A, ALL_LISTS B, TESTCYCL C Where B.AL_FATHER_ID = A.AL_ITEM_ID And C.TC_STATUS = B.AL_DESCRIPTION And A.AL_DESCRIPTION = 'Status' And (C.TC_EXEC_DATE = @ExecutionDate

  • Why does kanji script appear superimposed on tabs and then appear in an e-mail message from a known commercial sender?

    More than once as I am working with 3 or more open tabs, kanji script appears superimposed across the tabs. Won't respond to right or left clicking, haven't tried highlighting. Today while opening email on yahoo, a message appeared in my inbox with k