Text to binary (.txt to .bin)

Hello,
I'm developing an application on J2ME that needs to read from files.
I want to use binary files instead text files, because I think that in this way I have two benefits:
1. reducing the jar size
2. speeding up the reading process.
that's the starting point...and I hope this approach is right.
I've developed a small class in J2SE just as an utility to convert .txt files in .bin files and...GULP!!!...a txt file of 22KB becomes 44KB converted in .bin...there is something wrong, but I don't know.
here is the code I wrote:
package texttobin;
import java.io.*;
public class Main {
    public static void main(String[] args) {
        File inFile  = null;    //the file to read
        File outFile = null;    //the file to write
        //read the path from commandline
        if (args.length > 0)
            inFile = new File(args[0]);
            outFile = new File(args[1]);
        //some checkings
        if (inFile == null) return;
        if (outFile == null) return;
        try {
            //setup the streams
            FileOutputStream outputStream = new FileOutputStream (outFile);
            DataOutputStream dataOutputStream = new DataOutputStream (outputStream);
            FileInputStream sourceStream = new FileInputStream(inFile);
            byte readingByte[] = new byte[1];
            while(true) {
                if (sourceStream.read(readingByte)!=-1) {
                    //to be sure: I convert the readed input byte in a string
                    //and pass the char inside to the writeChar method...
                    dataOutputStream.writeChar(new String(readingByte).charAt(0));
                    //the same result is achieved with:
                    //dataOutputStream.writeChars(new String(readingByte));
                else break;
            dataOutputStream.close();
            outputStream.close();
            sourceStream.close();
        catch(FileNotFoundException fnfe)
            System.out.println (fnfe);
            return;
        catch(IOException ioe)
            System.out.println (ioe);
            return;
}WHAT'S WRONG?!
THANKS A LOT!!!
daniele

ZIP it or use a 7-bit encoding scheme (which isn't
easy). As for faster reading: you need to see that
the decoding of your file format doesn't take more
time than the reading of an unencoded format would
take.Yes, you're right, but I thought that the bottleneck is the reading process, not the decoding algorhytm (hopefully!!!)
I found an article that say:
An ASCII file is a binary file that stores ASCII codes. Recall that an ASCII code is a 7-bit code stored in a byte. To be more specific, there are 128 different ASCII codes, which means that only 7 bits are needed to represent an ASCII character.
However, since the minimum workable size is 1 byte, those 7 bits are the low 7 bits of any byte. The most significant bit is 0. That means, in any ASCII file, you're wasting 1/8 of the bits. In particular, the most significant bit of each byte is not being used.
http://www.cs.umd.edu/class/spring2003/cmsc311/Notes/BitOp/asciiBin.html
(and sorry for the mistake: 7-bit not 7 bytes!!!)
another intrested thing I've found is here:
http://www2.sys-con.com/ITSG/virtualcd/Java/archives/0607/heaton/index.html
there is some ways to store strings in bin files (like fstream in C++), but I didn't tested yet if in this way I can reduce the size of the bin.
The files are stored in the jar file, then zipping maybe can reduce more the size of the jar, but I think that when the stream opens it takes the real bytes of the contained text (well...I'm not sure...may you confirm it?)
thank you.

Similar Messages

  • Text to binary

    Hello All,
    i want to know what and all ways i can read the data in j2me for example prayer times.
    one of my old colleague used text to binary conversion. but he is not in contact to ask the help. can anyone help me in regard to this.
    thanks in advance

    also any idea on how to unconvert the binary value
    back to normal text?? i came up with this Have you executed this code? You aren't converting anything here. You need to convert each byte to a char and append that to your buf.
    When you post code, please put your code between [code][/code] tags for readability.
    >
    public class test
    public static void main(String args[])
    StringBuffer buf = new StringBuffer();
    String str="01101000011001010110110001110000";
    if((str.length()%2)==1)
    System.err.print("bad bin string");
    else
    for(int i=0;i<str.length();i+=8)
    buf.append(str.substring(i,i+7));
    System.out.println(buf);
    i use the remainder of 1 to check to see is it a good
    string or a bad 1, thats why i need the 8 digits

  • Text file 'engineOnClose.txt'

    I keep getting the following text file 'engineOnClose.txt' everytime I quit my browser.  Does anybody know why I'm getting this file, as I've not see it before?

    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.io.IOException;
    public class Test
        public static void main(String[] args)
            try
                BufferedReader in = new BufferedReader(new FileReader("xxx.txt"));
                int i = 1;
                String line = in.readLine();
                while (line != null)
                    System.out.println(i + ": " + line);
                    ++i;
                    // Read next line
                    line = in.readLine();
                in.close();
            catch (IOException ioe)
                System.out.println("An I/O exception occurred");
                ioe.printStackTrace();
    }Jesper

  • Pulling text from a .txt to a scroll pane or text area

    Hi-
    I'm sure there's a way to do this, but I'm not exactly fluent in ActionScript.
    Basically, my whole website's going to be in Flash, but I want to be able to update one page (sort of a news/blog page) without having to edit the Flash file every time. I'm assuming the easiest way to do this would be to set up either a scroll pane or a text box and pull the text in from a .txt file (if there's a better way, please let me know). That way I could continue to add on to the .txt file, and Flash would always pull in the current version.
    So, my issues are:
    1. I have no idea where to start with the code for something like that. Is it a LoadVar? Do I physically put a scroll pane or a text area in the frame and put the action on that, or do I put the action on the frame and have it call up a text area component?
    2. Will the text scroll automatically, or is that something else I would have to add in? I plan on adding to this text file for awhile, so it could end up being a lot of text over time.
    3. Would I be able to format the text in the .txt at all? For instance, if I hit enter to put in a paragraph break, would that register once it's pulled into Flash, or would I have to put in an html paragraph break or something? That may be a dumb question, but as I said, I'm not exactly fluent in ActionScript (or any other programming language for that matter).
    Any help is definitely appreciated!
    Thanks!
    -Geoff

    I recommend you use an xml file rather than a text file for storing your content.  The main reason being that it tends to make thing more easily organizable, as well as easier to differentiate things like titles, contents, links, images, etc.
    You could start off using a TextArea component if you want, just to keep things simple.  If you want to format things you can use the htmlText property rather than the text proiperty when assigning your content.  That will allow you more control of the presentation.
    If you want to take the xml approach, you should search Google for "AS# XML tutorial" where you substitute whatever version you plan to use for the "#".  If you plan to use AS3, there is a good tutorial here: http://www.gotoandlearn.com/play?id=64

  • Importing Text From A .txt File

    Hey guys,
    I'm looking for a way to import text from a .txt file but I'm totally lost. If someone could point me in the right direction that would be awesome

    Hi Prails
    This script is basically what you asked:
    #target illustrator
    #targetengine main
    function copyText(){
        var textFile = File.openDialog ("Select the file");
        if (! textFile.exists || app.documents.length==0){
            return;
        textFile.open("r");
        var txtContent = textFile.read();
        textFile.close();
        var doc = app.activeDocument;
        var textItem = doc.textFrames.add();
        textItem.contents = txtContent   
    copyText ();
    Basically what you need to do is declare the text file, open it, read the content and close it. Then, you create a new text item in the Illustrator document and write the content once catched into the text item.
    You could continue to work with the variable "textItem" in my example script if you want to set properties like the size, color of the text, position and so on. Also, if you want, replace the first line of the function var textFile = new File ("~/Desktop/Test.txt"); by var textFile = File.openDialog ("Select the file"); so the scripts opens a dialog to ask you the file you want the copy the content.
    Hope to be helped
    Best Regards
    Gustavo
    Message was edited by: Gustavo Del Vechio

  • Loading text from a .txt file

    I want to do something that should be VERY simple, but due to
    Adobe's insistence on using #$%^ing tutorials instead of just
    providing step by step instructions, it's very frustrating to
    figure out how to do it.
    All I want to do is load the contents of a text file into a
    dynamic text field, but I can't figure out how to do it (I'm not
    all that familiar with AS). I'm working with Flash 8. Please help.
    Thanks.

    Create the dynamic text box, and name it schedule.
    Then, in the frame on the timeline that the text box resides
    in, the corresponding actionscript would be used to create a text
    variable and assign the text from a txt file to it:
    loadText = new LoadVars();
    loadText.load("externalfile.txt");
    loadText.onLoad = function() {
    schedule.text = this.textbody;
    Where does the "textbody" variable come from? In the external
    text file (externalfile.txt in this example), you have a variable
    called textbody, and the externalfile.txt should read along the
    lines of:
    textbody = "I'm the external text that needs to be read
    in"

  • Error message "SiteFile.getCRC called with no text or binary content" when trying to publish site to Business Catalyst

    I'm trying to publish my site to business catalyst, but keep getting a pop-up message and muse shuts down. The error message says "SiteFile.getCRC called with no text or binary content".
    No issues before, but I made a few font changes and now I won't upload. I've updated Air and uninstalled/reinstalled Muse. Not sure what the issue or where to start.
    Thanks for the help!

    Could you please share your .muse file with us to investigate? Please email it to [email protected] If your file is greater than 20MB you can use something like Adobe SendNow or SendThisFile or Dropbox. Please do not forget to mention the link to this forum thread in your e-mail so that we can identify the file.

  • Can anyone post me a solution for converting gif containing text to a .txt

    Can anyone post me a solution for converting gif containing text to a .txt file using Java

    wow!!!
    not gonna put a full solution (since its huge!!!)
    but heres how you would do it
    open the gif in a bufferd image, then do some image recognition on it
    easy (hehe) case is if the gif only contains text (black on white of a standard font)
    then i would scan down the image until i find a raster line that isnt all white (top of a text line), then find the next raster line that is all white (bottom of text line.
    half(ish) way between these lines scan from the left until you find a black pixel (start <maybe> of next character) (be careful you dont aim for the gap in "i"
    from that point (x, y) test a set of pixels (x+n1, y+m1) to (x+nt, x+mt) where t should only have to be ~8 or 10 such that for each character in the font these test points return a unique combination, you then know what character is next, add it to a string and repeat along the line, then down the page
    tahh dahh there ya go
    you can write a program to learn the required test points by giving it a line of the full character set
    good piggin luck is what i say :-)

  • Receiving text versus binary

    Hello,
    I am hoping someone tells me about this basic query I had in my mind..
    what is the difference between sending /receiving files in text versus binary from server when we do FTP...?
    How is text passed? - If someone intercepts can they read? How is it passed by machine.. using what ? like FileOutputStream ? or what ? And how do people intercept ?
    Thank you.

    Text vs binary can be explained quite simply. It goes down to computer architecture - bits and bytes.
    Theres a link here:
    http://www.cs.umd.edu/class/spring2003/cmsc311/Notes/BitOp/asciiBin.html
    Basically ascii text only requires 7 bits of info to be transferred. In order to save data transmission time, only the relevant 7 bits are transferred, and the 8th bit is assumed to be a 0.
    Binary files take into account all 8 bits in a byte. You need ALL the information to make sense of it. So when transferring a binary file you send all 8 bits of a byte.
    Switching between binary/text mode for sending basically tells it how to handle the incoming data - as binary (just read it) or text (read 7, add an extra blank 0)
    Cheers,
    evnafets

  • How to use automator to extract specific text from json txt file

    I'm trying to set up an Automator folder action to extract certain data from json files. I'm pulling metadata from YouTube videos, and I want to extract the Title of the video, the URL for the video, and the date uploaded.
    Sample json data excerpts:
    "upload_date": "20130319"
    "title": "[title of varying length]"
    "webpage_url": "https://www.youtube.com/watch?v=[video id]"
    Based on this thread, seems I should be able to have Automator (or any means of using a shell script) find data and extract it into a .txt file, which I can then open as a space delimited file in Excel or Numbers. That answer assumes a static number of digits for the text to be extracted, though. Is there a way Automator can search through the json file and extract the text - however long - after "title" and "webpage_url"?
    json files are all in the same folder, and all end in .info.json.
    Any help greatly appreciated!

    Hello
    You might try the following perl script, which will process every *.json file in current directory and yield out.csv.
    * CSV currently uses space for field separator as you requested. Note that Numbers.app cannot import such CSV file correctly.
    #!/bin/bash
    /usr/bin/perl -CSDA -w <<'EOF' - *.json > out.csv
    use strict;
    use JSON::Syck;
    $JSON::Syck::ImplicitUnicode = 1;
    # json node paths to extract
    my @paths = ('/upload_date', '/title', '/webpage_url');
    for (@ARGV) {
        my $json;
        open(IN, "<", $_) or die "$!";
            local $/;
            $json = <IN>;
        close IN;
        my $data = JSON::Syck::Load($json) or next;
        my @values = map { &json_node_at_path($data, $_) } @paths;
            #   output CSV spec
            #   - field separator = SPACE
            #   - record separator = LF
            #   - every field is quoted
            local $, = qq( );
            local $\ = qq(\n);
            print map { s/"/""/og; q(").$_.q("); } @values;
    sub json_node_at_path ($$) {
        #   $ : (reference) json object
        #   $ : (string) node path
        #   E.g. Given node path = '/abc/0/def', it returns either
        #       $obj->{'abc'}->[0]->{'def'}   if $obj->{'abc'} is ARRAY; or
        #       $obj->{'abc'}->{'0'}->{'def'} if $obj->{'abc'} is HASH.
        my ($obj, $path) = @_; 
        my $r = $obj;
        for ( map { /(^.+$)/ } split /\//, $path ) {
            if ( /^[0-9]+$/ && ref($r) eq 'ARRAY' ) {
                $r = $r->[$_];
            else {
                $r = $r->{$_};
        return $r;
    EOF
    For Automator workflow, you may use Run Shell Script action as follows, which will receive json files and yield out_YYYY-MM-DD_HHMMSS.csv on desktop.
    Run Shell Script action
        - Shell = /bin/bash
        - Pass input = as arguments
        - Code = as follows
    #!/bin/bash
    /usr/bin/perl -CSDA -w <<'EOF' - "$@" > ~/Desktop/out_"$(date '+%F_%H%M%S')".csv
    use strict;
    use JSON::Syck;
    $JSON::Syck::ImplicitUnicode = 1;
    # json node paths to extract
    my @paths = ('/upload_date', '/title', '/webpage_url');
    for (@ARGV) {
        my $json;
        open(IN, "<", $_) or die "$!";
            local $/;
            $json = <IN>;
        close IN;
        my $data = JSON::Syck::Load($json) or next;
        my @values = map { &json_node_at_path($data, $_) } @paths;
            #   output CSV spec
            #   - field separator = SPACE
            #   - record separator = LF
            #   - every field is quoted
            local $, = qq( );
            local $\ = qq(\n);
            print map { s/"/""/og; q(").$_.q("); } @values;
    sub json_node_at_path ($$) {
        #   $ : (reference) json object
        #   $ : (string) node path
        #   E.g. Given node path = '/abc/0/def', it returns either
        #       $obj->{'abc'}->[0]->{'def'}   if $obj->{'abc'} is ARRAY; or
        #       $obj->{'abc'}->{'0'}->{'def'} if $obj->{'abc'} is HASH.
        my ($obj, $path) = @_; 
        my $r = $obj;
        for ( map { /(^.+$)/ } split /\//, $path ) {
            if ( /^[0-9]+$/ && ref($r) eq 'ARRAY' ) {
                $r = $r->[$_];
            else {
                $r = $r->{$_};
        return $r;
    EOF
    Tested under OS X 10.6.8.
    Hope this may help,
    H

  • Text to binary convertion

    this lil code supposed to print out the binary value of what is in the string, however when a "!" or a " " space is passed i dont get the 8 digits instead i get 7
    " " = 0100000
    not 00100000 (the value i supposed )
    here is the code that i came up with
    public class convert
    public static void main(String[] args)
    StringBuffer buffer = new StringBuffer();
    String s = " ";
    for (int i = 0; i < s.length(); i++)
    buffer.append(00000000+Integer.toString(s.charAt(i),2));
    System.out.println(buffer);
    }

    also any idea on how to unconvert the binary value
    back to normal text?? i came up with this Have you executed this code? You aren't converting anything here. You need to convert each byte to a char and append that to your buf.
    When you post code, please put your code between [code][/code] tags for readability.
    >
    public class test
    public static void main(String args[])
    StringBuffer buf = new StringBuffer();
    String str="01101000011001010110110001110000";
    if((str.length()%2)==1)
    System.err.print("bad bin string");
    else
    for(int i=0;i<str.length();i+=8)
    buf.append(str.substring(i,i+7));
    System.out.println(buf);
    i use the remainder of 1 to check to see is it a good
    string or a bad 1, thats why i need the 8 digits

  • Text layers from .txt file for buisness cards

    I have a template for a business card that I created for a company. So  imagine I have a background layer which is the card itself, and above  that a layer for each string of text on the card (name, title, phone,  email). Up until now, I would manually enter all the information using  the Type tool to edit each text layer. However, it has become very  tedious and I know there has to be a much easier way to do this. I'm  looking for a way to automate this process.  So far I have created an Excel database of all the  employees, and I export each employees information to a .txt file that  looks like this:
    John Doe
    Job Title
    123-456-7890
    123-456-7890
    [email protected]
    Each line in the .txt file corresponds to a text layer on the .psd. I've  tried following a tutorial from the web (kirupa.com - Photoshop Scripting) but he is creating  them in batches which is not what I need to do. And quite frankly, it's  a bit over my head. I know scripting must be the way, but unfortunately  I don't know much about JaveScript or any  other language for that matter.
    I know it's a lot to ask for, but if anyone could show me how to write a  simple script for this or point me in the right direction, it would be  much appreciated. And I mean MUCH!

    Hey man, that was spot on! This does exactly what I was looking for, now scripting required. Thanks for the help, I really appreciate it.

  • Dynamic Text with external .txt files

    I need help getting dynamic text to display. I've used the
    following tutorials (among others).
    http://www.kirupa.com/developer/mx/dynamic_scroller.htm
    http://www.kirupa.com/developer/mx/multiple_dynamictext.htm
    In Flash 8 on last frame of maintimeline of movie, I have a
    layer with a background image, 2 buttons and a dynamic textbox
    (made scrollable) with scrollbar component. Textbox is given a var
    of "content", and an instance name of "textBox", which is
    referenced in scrollbar parameters.
    I have created 3 text .txt files, and saved them to same
    folder with movie .swf file. Text in files is preceeded by
    "content=" on line preceeding text to correspond with var of
    dynamic textbox. The files were created in Rich text format on Mac
    OSX4.11 and saved with .rtf extension, then file extension was
    changed to .txt (wouldn't save as .txt)
    I've added the following actionscript to this last frame:
    loadText = new LoadVars();
    loadText.load("TEXTintro.txt");
    //creating the loadVarsText function
    loadText.onLoad = function(success){
    if (success){
    textBox.text = this.content;
    else{
    trace("Error loading external content");
    Buttons have an instance name assigned with the following
    actionscript:
    on (release) {
    loadText = new LoadVars();
    loadText.load("TEXT1.txt");
    loadText.onLoad = function(success){
    if (success){
    textBox.text = this.content;
    else{
    trace("Error loading external content");
    When I test movie, I can see buttons on last frame of movie,
    but they don't load any text when pressed, and "undefined" text
    appears in upper left corner of text box before I press either
    button.
    I am getting the following Output errors:
    **Error** Scene=MoonOfWintertime, layer=TextBox,
    frame=2500:Line 1: Statement block must be terminated by '}'
    on (release) {
    **Error** Scene=MoonOfWintertime, layer=TextBox,
    frame=2500:Line 11: Syntax error.
    **Error** Scene=MoonOfWintertime, layer=TextBox,
    frame=2500:Line 1: Statement block must be terminated by '}'
    on (release) {
    **Error** Scene=MoonOfWintertime, layer=TextBox,
    frame=2500:Line 11: Syntax error.
    Total ActionScript Errors: 4 Reported Errors: 4

    No more output errors, buttons still not working, but I got
    my intro .txt file to load in textbox that loads with frame using
    the following code I tried from another tutorial:
    loadText = new LoadVars();
    loadText.onLoad = function() {
    textBox.html=true;
    textBox.htmlText = this.textContent;
    loadText.load("TEXTintro.txt");
    Tried the following code with buttons, but doesn't work.
    Other code suggestions?
    on (release) {
    loadText = new LoadVars();
    loadText.onLoad = function() {
    loadText.load("TEXT2.txt");
    on (release) {
    loadText = new LoadVars();
    loadText.onLoad = function() {
    textBox.html=true;
    textBox.htmlText = this.textContent;
    loadText.load("TEXT1.txt");
    }

  • Importing fixed width text from a .txt file

    I am really struggling to do in Numbers '09 something which I can do easily in Excel.
    I have a txt file containing plain text in fixed-width columns which I would like to import into numbers.
    I just cannot find a way to do it.
    I have tried using the Insert/choose menu item - but it won't take .txt files.
    I have tried to copy/paste the data, but it get's pasted into a single column.
    The data consists of many lines like this:
    Part Value Device Package Library Sheet
    A-IN JST-2.0-4 JST-2.0-4 JST-20M KMILLAR 1
    A-IN JST-2.5-4 JST-2.5-4 JST-25M KMILLAR 1
    A-IN JST-2.8-4 JST-2.8-4 JST-28M KMILLAR 1
    (and so on....)
    (Each column is an exact number of characters wide, but these forums make that hard to see due to the variable spaced fonts).
    How can I import this data into numbers?
    (Sorry, but I cannot get the data in any other format, such as CSV, the application which exports it only support fixed width colums with spaces for padding).
    Many thanks in advance,
    Kenny

    Here is a script treating the case of fixed widths values.
    --[SCRIPT fixedwidth_values_toTSV.scpt]
    Enregistrer le script en tant que Script : fixedwidth_values_toTSV.scpt
    déplacer le fichier ainsi créé dans le dossier
    <VolumeDeDémarrage>:Users:<votreCompte>:Library:Scripts:Applications:Numbers:
    Il vous faudra peut-être créer le dossier Numbers et peut-être même le dossier Applications.
    aller au menu Scripts , choisir Numbers puis choisir fixedwidth_values_toTSV
    Choisir un fichier texte.
    Le script détermine la largeur des différentes colonnes puis remplace les groupes séparateurs par des caractères TAB.
    Le résultat est passé dans le presse-paiers et est enregistré à la place du contenu initial.
    Vous pouvez alors
    (1) coller dans le document de votre choix
    (2) ouvrir le fichier texte modifié dans Numbers qui accepte sans broncher les ficiers .txt.
    Utilisation alternative : enregistrer le script en tant que Progiciel (Application sous 10.6.x)
    Glisser-déposer l'icône d'un fichier texte sur celle de l'application lancera le traitement voulu.
    --=====
    L'aide du Finder explique:
    L'Utilitaire AppleScript permet d'activer le Menu des scripts :
    Ouvrez l'Utilitaire AppleScript situé dans le dossier Applications/AppleScript.
    Cochez la case "Afficher le menu des scripts dans la barre de menus".
    Sous 10.6.x,
    aller dans le panneau "Général" du dialogue Préférences de l'Éditeur Applescript
    puis cocher la case "Afficher le menu des scripts dans la barre des menus".
    --=====
    Save the script as a Script: fixedwidth_values_toTSV.scpt
    Move the newly created file into the folder:
    <startup Volume>:Users:<yourAccount>:Library:Scripts:Applications:Numbers:
    Maybe you would have to create the folder Numbers and even the folder Applications by yourself.
    go to the Scripts Menu, choose Numbers, then choose "fixedwidth_values_toTSV"
    Choose a text file.
    The script scan the file's contents to extract the width of every column then it replace the separator groups by TAB characters.
    The result is passed to the clipboard and is written in the original file.
    So you may :
    (1) paste in the document of your choice
    (2) open the modified text file with Numbers which is fair enough to do that.
    An alternate track is to save the script as an Application Package (Application under 10.6.x)
    Drag and drop the icon of a text file on the application's one will do the job.
    --=====
    The Finder's Help explains:
    To make the Script menu appear:
    Open the AppleScript utility located in Applications/AppleScript.
    Select the "Show Script Menu in menu bar" checkbox.
    Under 10.6.x,
    go to the General panel of AppleScript Editor’s Preferences dialog box
    and check the “Show Script menu in menu bar” option.
    --=====
    Yvan KOENIG (VALLAURIS, France)
    2010/08/19
    --=====
    on run
    set un_fichier to choose file with prompt "Choose e text file…" of type {"public.plain-text"} without invisibles
    my commun(un_fichier)
    end run
    --=====
    on open (sel)
    set un_fichier to item 1 of sel
    tell application "System Events" to set type_ID to type identifier of disk item ("" & un_fichier)
    if type_ID is "public.plain-text" then my commun(un_fichier as alias)
    error "The file “" & un_fichier & "” isn’t a text file !"
    end open
    --=====
    on commun(le_fichier)
    set le_contenu to read le_fichier
    set le_contenu to "azer ertyuio wxcv dfghj
    qszaed dc fghj mlkjhgf nbvcxw
    aqwzsx edcrfv tg byhn aaaaaaa "
    set listedelistes to {}
    set plusgrandelongueur to 0
    set pluspetitelongueur to 999999
    set listelignesbrutes to paragraphs of le_contenu
    repeat with refd_uneligne in listelignesbrutes
    set maybe to contents of refd_uneligne
    set maybe2 to count of maybe
    if maybe2 > plusgrandelongueur then set plusgrandelongueur to maybe2
    if maybe2 < pluspetitelongueur then set pluspetitelongueur to maybe2
    copy my decoupe(maybe, space) to end of listedelistes
    end repeat
    set differencedelongueur to plusgrandelongueur - pluspetitelongueur
    set des_espaces to space
    repeat differencedelongueur times
    set des_espaces to des_espaces & space
    end repeat
    set largeur1 to 0
    repeat with refd_uneligne in listedelistes
    set maybe to length of first item of refd_uneligne
    if maybe > largeur1 then set largeur1 to maybe
    end repeat
    set liste_finale to {}
    repeat with refd_uneligne in listelignesbrutes
    set maybe to contents of refd_uneligne
    set maybe2 to text 1 thru largeur1 of maybe
    repeat while maybe2 ends with space
    set maybe2 to text 1 thru -2 of maybe2
    end repeat
    copy maybe2 to end of liste_finale
    copy text (largeur1 + 2) thru plusgrandelongueur of (maybe & des_espaces) to contents of refd_uneligne
    end repeat
    Enter the bigger loop *)
    set cest_Lafin to false
    repeat
    Deprieve the stored rows of the treated column's items *)
    set flag to 0
    repeat
    set flag to flag + 1
    set flag2 to 0
    repeat with refd_uneligne in listelignesbrutes
    if "" & character flag of contents of refd_uneligne is space then set flag2 to flag2 + 1
    end repeat
    if flag2 < (count of listelignesbrutes) then exit repeat
    end repeat
    repeat with refd_uneligne in listelignesbrutes
    copy text flag thru -1 of contents of refd_uneligne to contents of refd_uneligne
    end repeat
    Prepare the extraction of next column *)
    repeat with refd_uneligne in listelignesbrutes
    copy my decoupe(contents of refd_uneligne, space) to end of listedelistes
    end repeat
    Extract the width of the column to treat *)
    set largeur1 to 0
    repeat with refd_uneligne in listedelistes
    set maybe to length of first item of refd_uneligne
    if maybe > largeur1 then set largeur1 to maybe
    end repeat
    Extract the column's values *)
    repeat with i from 1 to count of listelignesbrutes
    set maybe to contents of item i of listelignesbrutes
    set maybe2 to text 1 thru largeur1 of maybe
    repeat while maybe2 ends with space
    set maybe2 to text 1 thru -2 of maybe2
    end repeat
    copy (contents of item i of liste_finale) & tab & maybe2 to item i of liste_finale
    try
    copy text (largeur1 + 2) thru -1 of maybe to item i of listelignesbrutes
    on error
    set cest_Lafin to true
    end try
    end repeat -- i
    if cest_Lafin then exit repeat
    end repeat -- bigger loop
    set le_contenu to my recolle(liste_finale, return)
    set the clipboard to le_contenu
    set eof of le_fichier to 0
    write le_contenu to le_fichier
    end commun
    --=====
    on decoupe(t, d)
    local oTIDs, l
    set oTIDs to AppleScript's text item delimiters
    set AppleScript's text item delimiters to d
    set l to text items of t
    set AppleScript's text item delimiters to oTIDs
    return l
    end decoupe
    --=====
    on recolle(l, d)
    local oTIDs, t
    set oTIDs to AppleScript's text item delimiters
    set AppleScript's text item delimiters to d
    set t to l as text
    set AppleScript's text item delimiters to oTIDs
    return t
    end recolle
    --=====
    --[/SCRIPT]
    Yvan KOENIG (VALLAURIS, France) vendredi 20 août 2010 12:44:33

  • How to read a file with both text and binary data?

    For text data I use a BufferedReader,
    for binary data I use a DataInputStream.
    Since readLine is deprecated in DataInputStream, how can I read in a proper way a file that contains some lines of text followed by some binary data.
    Is there a way to do this without writing a new 'readLine' for DataInputStream (that has to take into account the different newlines for Unix en other OS's)?

    sorry about that ^
    NEW STRING str
    WHILE there is stuff in the file DO
        getByte()
        IF reading a string THEN
            WHILE byte is not a return character DO
                convert the byte to character/string
                append char to str
            WEND
        ELSE IF reading raw data THEN
            parse raw data
            do stuff with it
        END IF
    WEND

Maybe you are looking for

  • Problems updating from OSX 10.6.7 to 10.6.8

    I've installed the new FCPX update on my iMac system, my second system, and it appears to be working fine. As part of the process I had to update the OS to 10.6.8 from 10.6.7. So I felt that was successful and have tried to do the same on my mac towe

  • Macbook Pro Melted Its Own Casing - Expert eyes needed on this photo please of my macbook pro

    This is a 2008 15" Macbook Pro. At the genius bar I pointed out that the computer was so hot I could barely hold it, so hot the computer had warped it's own plastic casing where it connects to the power source. So the genius guy took it in the back,

  • Alternative to Apple TV for composite video

    Like 80% of Americans, I don't have a high-definition TV. My TV only supports composite video input (a yellow RCA plug) or analog coaxial input. I had hoped to be able to use an Apple TV to watch video purchased from the iTS on my TV. It appears that

  • Exporting data from arraylist to excel

    I'm working on a program, in which data is uploaded from an excel spreadsheet, modified through an arraylist and the UI, then dumped back to the excel spreadsheet... Currently, I can save the data to an xls spreadsheet, but it is actually saved as a

  • Run Command through Java Program.

    I am giving ping command in exec method of Runtime(). But ping syntax is different for linux and windows. So when I run command on windows it wasn't worked. I am giving command --> ping -c5 ipaddress . This works fine for linux but in windows, there