Keynote: writing characters vertically

Simple question, but no simple answer it seems. I am preparing a Keynote presentation and want my writing to appear as columns beginning from the top. So the following statement, "How are you?" would appear as:
             y   H
             o   o
             u   w
                  a
                  r
                  e
Any suggestions on how to do this? The closest information I can find is rotating the text, which is not what I need.

getchell76 wrote:
Is that all Apple can offer? It is quite a crude solution and does not help for other languages like Japanese where the position and angle of the characters change depending on the direction of the script.
Apple makes it clear on the iWork purchase pages that Asian vertical text is not yet supported:
So for that kind of thing you need to use someone else's apps.  But Apple's TextEdit app does support Asian vertical text.
For the kind of thing you see in PowerPoint, I think you can do something similar by manipulating text boxes in Keynote (rather than using returns):

Similar Messages

  • Writing text vertically and drawing dashed line

    Hello,
    I m trying to write text vertically ( basically to write data on the y-axis of a graph)..Is there a way in which i can set the line direction properties to VERTICAL..?
    Also, i m trying to draw a dashed line.Can anyone tell me how to do this?
    Thnx in advance....

    Try looking [url http://www.macdevcenter.com/pub/a/mac/2002/03/22/vertical_text.html]here.
    : jay

  • Writing characters 0x80 through 0x9F to a text file

    I'm trying to write the full range of characters 0 to 255 to a file. I used the code below to do this. It works fine except for the range 0x80 to 0x9F. Is there a way to do this without Java converting these characters on its own?
    import java.io.*;
    public class GenerateHex
        private static ObjectOutputStream output;
        public static void main(String args[])
            System.out.println("Generating file");
            char c = '\0';
            try
                FileOutputStream fos = new FileOutputStream("C:\\Hex.txt");
                PrintStream out = new PrintStream(fos);
                for (int i = 0; i <= 255; i++)
                    out.print((char)i);
                    out.flush();
                out.close();
            catch(IOException ioException)
                System.out.println("Error");
                System.exit(0);
    }

    You need to get clear in your mind the relationship between characters and bytes in java (which is different from, say, C).
    To java a char variable holds a 16-bit UNICODE character, with separate values for all kinds of non-latin characters including Arabic, Hebrew, Japanese etc..
    A byte, on the other hand, is just an 8 bit number. Since files consist of streams of bytes java needs conversion operations when it reads or writes character data to and from files. This conversion is handled by Reader and Writer classes which sit on top of the byte oriented Stream classes. When a Reader or Writer is set up it has a character encoding scheme, which may be specified explicitly or, if not, defaults to the encoding scheme specified as normal for your machine's location.
    The PrintStream class is actually a hang-over from the time before java was internationalised. Although called a stream it's actually more like a Writer. In my opinion PrintWriters are best avoided.
    The default character encoding user by PrintStream is probably "US-ASCII", which is 7-bit.
    The character encoding which simply takes the characters in the range 0-255 and maps them to bytes is
    "ISO-8859-1".
    To write to a file using a specified encoding, rather than the default use:
    Writer out = new OutputStreamWriter(new FileOutputStream("test.txt"), "ISO-8859-1");

  • E71 also steals characters when writing characters...

    Whenever I write a text message and use one of those character á,ã,í,ó,õ,ú or č,ć,š,đ,ž (Serbian Latin) for the first time in a message it takes 91 characters. And when you use it for the second, third... time it takes 1 ch. WHY?
    That is also a problem on all other nokia symbian phone (my experience with 3650, n70, n73). I don't have this problem on NONsymbian nokia phones and all other non nokia phones.

    Is that phenomenon similar to this: "normal" English characters take up 1 character. But mix Chinese characters the count jumps by around 50% more.
    I've learnt to not mix English and Chinese messages whenever possible.
    Never got around to finding out why though
    E71! Lovin' It!

  • Optional Vertical Space Character

    Paragraphs can have a "space before" and "space after" attribute, as you probably know. The nice thing about this is that if the paragraph is at the top of the page, the space before disappears.
    I would like to have a vertical space character that does the same. You insert it into a line by itself (Type>Special Characters>Vertical Spacer). It makes a vertical gap based on the leading you give it.
    BUT! if it appears as the top line of a text frame, it will disappear.
    Why is this good? Because it saves having to create a lot of paragraph styles to deal with each situation. For instance, currnetly, I may need the following styles:
    Block Quote Standalone [space before and space after]
    Block Quote beginning [space before no space after]
    Block Quote Middle [no space before no space after]
    Block Quote End [no space before space after]
    Block Quote Standalone Indented
    Block Quote beginning Indented
    Block Quote Middle Indented
    Block Quote End Indented
    That's 8 styles all for the different combinations of block quotes. If I had a "vertical space" character, I would need only two styles:
    Block Quote; and
    Block Quote Indented.
    Much easier to manage! The variations could be simply managed by inserting a vertical spacer as needed. Really useful idea, and similar to the way dedicated typesetting systems used to work several decades ago.
    Thanks,
    Ariel

    Perhaps. Not sure I understand. Could you elaborate?
    But let me explain. Here's an example. A regular long block quote will need 3 styles, depending on whether there needs to be a line space before or after the paragraph:
         BlockQuoteBeginning BlockQuoteBeginning BlockQuoteBeginning
    BlockQuoteBeginning BlockQuoteBeginning BlockQuoteBeginning
    BlockQuoteBeginning BlockQuoteBeginning BlockQuoteBeginning
    BlockQuoteBeginning BlockQuoteBeginning BlockQuoteBeginning
         BlockQuoteMiddle BlockQuoteMiddle BlockQuoteMiddle BlockQuoteMiddle
    BlockQuoteMiddle BlockQuoteMiddle BlockQuoteMiddleBlockQuoteMiddle
    BlockQuoteMiddleBlockQuoteMiddleBlockQuoteMiddleBlockQuoteMiddle
        BlockQuoteEnd BlockQuoteEnd BlockQuoteEnd BlockQuoteEnd
    BlockQuoteEnd BlockQuoteEnd BlockQuoteEnd BlockQuoteEnd
    BlockQuoteEnd BlockQuoteEnd BlockQuoteEnd BlockQuoteEnd
    And then you need a separate style for a standalone block quote, that needs a line space both above and below. So that's 4 common styles.
    Then, occassionally, each of these for will sometimes not need indentation. So that's another four styles.
    Also, if the book requires block quotes in footnotes (a bad idea, IMHO, but the choice is not up to me), that's another 8 styles for the same reason.
    The forced line break that you mention, if I've understood correctly, wouldn't work with justified paragraphs, since it will force the line before the forced break to be fully justified?
    Ariel

  • Cannot read foreign characters!!!

    Requirement: Read a text file containing foreign characters and print it/ store it in string buffer
    Problems: Doesnt work, and throws exception whenever Reader.read() or BufferedReader.readline()
    method is envoked...
    How do i get arround this?
    Here is a sample text from the file...
    Ang�ende utleggelse av kopierte lydfiler i CVS8 format via internett � f� fjernet p� denne e-mail n�dt til � bemerke
    here is the sample program:
    import java.io.*;
    public class LoadUTF8 {
         private static String _FILE = null;
         public static void main(String args[]) {
              _FILE = args[0];
              try {
                   System.out.println(getUTF8());
              catch(Exception e) {e.printStackTrace();}
              try {
                   loadUTF8Data();
              catch(Exception e) {e.printStackTrace();}
         public static String getUTF8() {
              StringBuffer buffer = new StringBuffer();
              try {
                   FileInputStream fis = new FileInputStream(_FILE);
                   InputStreamReader isr = new InputStreamReader(fis, "UTF8");
                   Reader in = new BufferedReader(isr);
                   int ch;
                   while ((ch = in.read()) > -1) {
                        buffer.append((char)ch);
                   in.close();
                   return buffer.toString();
              } catch (IOException e) {
                   e.printStackTrace();
                   return null;
         public static void loadUTF8Data() {
    try
                   InputStream in = new FileInputStream(_FILE);
                   BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF8"));
                   String line = null;
                   StringBuffer buffer = new StringBuffer();
    while ( ( line = reader.readLine() ) != null ) // Read line until EOF
    buffer.append( line + "\n" );
    System.out.println("" + buffer.toString() + "");
              catch(Exception e) {
                   e.printStackTrace();
    Error Message:
    sun.io.MalformedInputException
    at sun.io.ByteToCharUTF8.convert(ByteToCharUTF8.java:110)
    at java.io.InputStreamReader.convertInto(InputStreamReader.java:137)
    at java.io.InputStreamReader.fill(InputStreamReader.java:186)
    at java.io.InputStreamReader.read(InputStreamReader.java:249)
    at java.io.BufferedReader.fill(BufferedReader.java:139)
    at java.io.BufferedReader.read(BufferedReader.java:157)
    at mtrack.cda.utils.LoadUTF8.getUTF8(LoadUTF8.java:25)
    at mtrack.cda.utils.LoadUTF8.main(LoadUTF8.java:15)
    NB:- It works fine with normal text files that doesn't have any foreign character!
    If either of getUTF8() or loadUTF8Data() functions work, i will be very happy!!! :-)

    Hi Pratim,
    Your code is absolutely correct and can be adapted to read in any foreign characters as long as you create your InputStreamReader with the same encoding that was used to write the file you are trying to read. By default, java encodes files in a format called Cp1252. Cp1252 can be used to encode ASCII characters (\u0000->\u007f) + an extended region (\u0080->\u00ff). This extended region contains, among other characters, the extra characters used by languages like Spanish, German etc. To read such a file, change your code to:
    InputStreamReader isr = new InputStreamReader(fis, "Cp1252"); However, if one wants to encode characters beyond \u007f (for example, Chinese, Hindu, Russian etc.) then one cannot use Cp1252 encoding. Frequently, such characters are encoded using UTF8 (Unicode Transformation Format 8). UTF8 is capable of encoding the entire unicode character set. There are many many different encodings supported by java. The point is that you must to use the same encoding to read back the characters as was used to store them.
    I suggest that you experiment with writing characters to files and reading them back into java using different encodings. You already have the code to read the characters. To write the files, you can either use Microsoft Word or you can write code analogous to your code above except using the OutputStreamWriter. It will also be helpful to you if you have some way of examining the bytes in your output files.
    Regards,
    Joe

  • Writing UTF8 encoded data on file system.

    Hi,
    Could some one tell me what is wrong with the following code.
    try
    fos = new FileOutputStream(new File ("A.txt")) ;
    catch(FileNotFoundException fnfe)
    throw new Exception ("FileUtility constructor 2 - FileNotFoundException ", fnfe);
    try
    // Create OutputStreamWriter to a fileOutputStream with encoding
    OutputStreamWriter osw = new OutputStreamWriter(fos, encoding_);
    // Create buffered writer over the OutputStreamWriter
    _buffWriter            = new BufferedWriter(osw);
    buffWriter.write(data,0,data_.length());
    _buffWriter.newLine();
    catch(IOException _ioException)
    GemmsUtility.showMsg("FileUtility writeData - IOException ["+ioException.toString()+"]",bDebug);
    _ioException.printStackTrace();
    catch(UnsupportedEncodingException usee)
    throw new Exception ("FileUtility constructor 2 - UnsupportedEncodingException ", usee);
    I find some junk characters in "A.txt". When I open "A.txt" i found some junk characters. Your help will be appreciated.
    Thanks
    -Sri

    You are retrieving characters from a character set.
    You are writing characters via a character set.
    And then you are viewing them via yet another character set.
    If one character set does not have a character that the other set does then you have a problem.
    Now it is possible that some of the above character sets are the same. Or they could all be different.
    I can however guarantee that with kanji that you are going to spend some time figuring it out.
    The first step is to verify what chars are in the database and what ones are in the text file.
    The way that you do that is to print the character values, in java, as hexadecimal values. Then you open the text file in a hexadecimal editor and see what is there. Then you create a text file with what should be there and compare the differences. It would also help if you could do the same thing in the database (using a database tool, not java.)

  • File I/O and encoding (J2SDK 1.4.2 on Windows)

    I encountered a strange behavior using the FileReader / Writer classes for serializing the contents of a java string. What I did was basically this:
    String string = "some text";
    FileWriter out = new FileWriter(new File("C:/foo.txt"));
    out.write(string);
    out.flush();
    out.close();In a different method, I read the contents of the file back:
    FileReader in = new FileReader(new File("C:/foo.txt"));
    StringWriter out = new StringWriter();
    char[] buf = new char[128];
    for (int len=in.read(buf); len>0; len=in.read(buf)) {
        out.write(buf, 0, buf.length);
    out.flush(); out.close(); in.close();
    return out.toString();Problems arise as soon as the string contains non ascii characters. After writing and reading, the value of the string differs from the original. It seems that different character encodings are used when reading and writing, although the doc states that, if no explicit encoding is specified, the platform's default encoding (in my case CP1252) will be used.
    If I use streams directly instead of writers, it does not work, either, as long as I do not specify the encoding when converting bytes to strings and vice versa.
    When I specify the encoding (no matter which one, as long as I specify the same for reading as for writing), the resulting string is equal to the original one.
    If I replace the FileReader and Writer by StringReader and StringWriter (bypassing the serialization), it works, too (without specifying the encoding).
    Is this a bug in the file i/o classes or did I miss something?
    Thanks for your help
    Ralph

    first.... if you are writing String objects via serialization, encoding doesn't matter whatsoever. Not sure you were saying you tried that, but just for future reference.
    For String.getBytes() and String(byte[]) or InputStreamReader and OutputStreamWriter: If you don't specify an encoding, the system default (or default specified on the command-line or set in some other way) will be used in all cases.
    For byte streams: If you are reading/writing bytes thru streams, then the character conversion is up to you. You call getBytes on a string or create a string with the byte[] constructor.
    For readers/writers: If you are reading/writing characters thru readers/writers, then the character conversion is done by that class.
    However, StringReader and StringWriter are just writing to/from String objects and they are writing Unicode char's, so it's really a special case.
    Okay...
    So if you have a string which has characters outside the range of the encoding being used (default or explicitly specified), then when it's written to the file, those characters are messed up. So say you have a Chinese character which needs 2 bytes. Generally, the 2 bytes are written, but when read back, that one character shows as 2. Whether 2 bytes are written or 1, probably depends on the encoding. But the result is the same, you get a munged up string.
    Generally speaking, you are going to get better storage on most text when using UTF-8 as your encoding. You need to specify it always for reads and writes, or set it as the default. The reason is that chars are written in as many bytes as needed. And it'll support anything Unicode supports, thus anything String supports.

  • HTML Stripping -- too much memory

    I have a program that takes data from a database and strips it of html tags. This is done over multiple tables. Some of the tables return a few thousand lines, but then others return about 65,000 lines. I open the file created and clean the needed fields with the following method. This causes an Out of Memory error with some of the larger files. Is there a better way to strip the html tags than I am using that would not throw this Out of Memory error?
          * Removes the html formatting for a string and stores it in a file
          * @return java.lang.String
          * @param htmlText java.lang.String
          * @param outputText java.lang.String
         public static String removeHtml(String htmlText) throws IOException     
              String returnValue = "";
              EditorKit kit = new HTMLEditorKit();          
              Document doc = kit.createDefaultDocument();          
              // The Document class does not yet handle charset's properly.          
              doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);          
              try          
                   // Create a reader on the HTML content.     
                   Reader rd = new StringReader(htmlText);
                   // Parse the HTML.               
                   kit.read(rd, doc, 0);               
                   //Set returnValue to cleaned text
                   returnValue = doc.getText(0, doc.getLength()).toString();
                   rd.close();
                   doc = null;               
                   kit = null;
              catch (Exception e)          
                   System.out.println ("ERROR: " + e.getMessage());
                   e.printStackTrace();          
              return returnValue;
         }

    There is a fairly trivial way where you just copy the characters from the input to the output, except for the following rules:
    1. When the input character is '<', stop writing characters to the output (including this one).
    2. When the input character is '>', start writing characters to the output (after this one).
    However this may stumble on malformed HTML, for example if the '<' character appears unescaped in text. I don't know if your data suffers from this problem or not.

  • Arabic LOV

    First of all thank you for your help,
    I am using Oracle 10g version: 10.1.2.0.2
    Mostly the database full of Arabic description and words, and my problem also in a field contain Arabic language,
    I tried all the regional settings possible to come over that problem without benefit.
    After I migrated from 6i to 10g, I have a problem with LOV behavior in the form:
    LOV appears good, but when I start writing in the find field it will not, Even when I put the cursor in the find field and start writing characters it doesn’t filtering its elements until I press enter, Also when I press enter and return to writing or changing the characters have been wrote I can’t do that until I put the cursor again in the find field and so on.
    In 6i when the LOV appears I am start typing the characters and the LOV do filtering while I writing character without press enter, even if I press enter and return to typing character inside the find field ,I can do it without moving mouse to put cursor there.
    any one overcome this case??

    Hi Massood,
    Why just LOV items? Shouldn't your entire application switch locale? That should be easier to achieve.
    Unfortunately we don't have out of the box support for Arabic locales but you can add that yourself as is also outlined in the JHeadstart developers guide (Chapter 11).
    Regards,
    Ruud

  • Black bar on left will not go away and covers slides

    WHen we use keynote a black vertical see through bar appeared on left covering the slides. This bar will not disappear and we can't access the individual slides anymore.
    CAn anyone help please.
    THanks

    yeah, this one nails a lot of my work too. i typically create
    all of my button images in a vector graphics application and import
    the BMPs into the general, over, and pressed button slots....now,
    my hover images always have a bolder, slightly larger font to them
    so that the user is fully 'aware' of what they're about to
    press...thing is, my tutorials invariably are fully
    backward/forward environments that typically do not even involve
    linear learning. they're more of a 'dig in and find some learnin'
    approach, meant for 'on the spot' learning....so what happens is
    whenever somebody 'revisits' a page, they'll see a button they'd
    already clicked in a 'hover' state, that stays that way until you
    're-hover' over it. annoying to say the least. same thing happens
    when you navigate backwards to a slide that contained a text box
    where the user entered info....something about each frame lacking a
    'wipe clean' command (i'm no coder, sorry for the layman's
    terminology)....
    hopefully that's present in 2.0....

  • Save Report to File.vi closing file problems

    I have a while loop running in which I generate data. At the end of a sequence in the while loop, I create an HTML report and save the report file to disk. My problem is that the next time the while loop generates data and goes to save the new HTML report, I get a file permission error (Error 8) in the delete file subvi. I use the delete file subvi so that I can programmatically replace the HTML report file. I believe that the problem is in the "Save Report to File.vi" in that it does not close the file after it writes it. Any comments?

    Unfortunately i couldn't open your example as i only have LV 6.0, but i looked at the 'Save report to File.vi' in LV 6.0 and it basically only contains a 'Write characters to file.vi' for file handling. In LV 6.0 this vi does contain a 'Close file+.vi' which has an input called 'close when? (now:T)'. Make sure this is wired as True (default) and the file will close, and you should be able to delete the file (as long as the delete event occurs afterwards (make sure it is wired in sequence). In the LV help, it says the reason for the 'Write characters to file.vi' only closing if you tell it to (set as default) or if there is an error is so you can continually use it in a loop, writing characters to file, without closing, and then send a command to close
    it only on the last loop, or if there is an error. Therefore i dont think it is a bug, but i think there should be a wire for it on the 'Write characters to file.vi'.
    I hope this helps you..
    Kim

  • Multi-threaded performance server using 2 ports to two-way communication

    Hi, I'm new in the forums so welcome everyone. I'm developing now an online computer game based on orginal Polish board-game, but it doesn't mean. Important is that I need to develope a high-performance multi-threaded server, which can serve... let's say few hundres of games, and a thousend of players simulateously. My server works on two ports/sockets.
    First one is represented by "ServerSocketChannel clientConSsc" in my code. The main thread in my server class which invokes the method "run()" (which You can see below), registers clientConSsc with Selector and then repeatingly accepts incoming connections from clients on this socket. When connection(channel) is estabilished and clients wants to write some request to this channel, the main thread on server creates a new instance of class "RequestHandler" which extends Thread and handles this request (reads the request from channel, makes some changes on server, spreads some new messages to other clients in the same game and so on... everything on the same socket/port/channel). Then the channel/connection is closed by the server - I call such connections: "a short connections". In the same time the main thread continues the loop and is still able to accept connections from another players. That's the idea of multi-threaded server, right? :) And to this point, everything works fine, but... what if the server wants to trigger some new command, write new information to client?
    Server could have tried to open a SocketChannel to client's IP address, but then the client programme would have to create and ServerSocketChannel object, bind it to some InetAddress and then... and then client becomes a server! - that breaks the idea of client-server cooperation and demands on players of my game to have routed some port on their machines. To resolve this problem I made some sort of "system" which, when some player/client is logging into my server, accepts second (this time constant, not "short") connection on the second port I mentoined on the beginning. This connection is held in variable "SocketChannel serverCon" of class "Player" - which reflects a player logged onto server. Server maintains every such connection till the client logs off. After the connection is accepted, the player whom connection it was is added to collection called "playersToRegisterToWrite". After the Selector.selectNow() is invoked (as You can see in the code below), each and every player's connection is registered in selector (with selection key - OP_WRITE and attachment pointing on owning player). In the same time client's code is trying to read some bytes from this connection and blocks on it until some bytes are written to this connection. When server wants to "tell" something to client, deliver some message/command, it creates a new instance of class which extends an abstract class called "ServerAction" (another new thread) and adds it to collection "actionsToDo". In ServerAction's method "run()" there are whole code to interact with client (e.g. send an update of players' list, an update of games' list, a chat message). Finnaly when Selector informs the server that some connection is writable (some client is waiting for commands), then server checks if there's any "actionToDo" involving this client/player. If there is, it unregisters the connection from Selector (so no other ServerAction (thread) can write on this connection) and starts the action. At the end of every "run()" method of subclass of ServerAction there's a code, which again adds the player to collection "playersToRegisterToWrite", so the player's connection can again be registered in Selector and the player can again receive informations from server - after it consumed THIS "ServerAction".
    It looks to me like it should be working fine, but it's not. When I test my server and clients on the same machine (no ping/latency) everything seems to be working fine. But when it comes to play my game with somebody even on LAN or through the Internet there comes the problems. My first socket I describe (and first type of connections - short connections) works perfectly fine, so the requests triggered by client are delivered and handled properly. But the second socket is cirppling. For example: the server triggers a command refering to an update of clients logged to server' list. It is triggered by Selector so the client should be ready to read data from server, so the server sends data! And the client never receives it... Why?
    It experimented a whole lot of time on SocketChannel's method "configureBlocking(boolean)", but it never helps. I think the client should always block it's listening thread on connection, contratry to server which is ment to be fast, so it should send the data through non-blocking channels. Am I right? Are there any rules refering blocking configuration of SocketChannels?
    I will be grateful for every answer. To help You out I attach also drafts from run()'s methods of my classes.
    Server's main method - main thread :
        public void run() {
           try {
                selector = Selector.open();
                clientConSsc.configureBlocking(false);
                clientConSsc.register(selector , SelectionKey.OP_ACCEPT);
                while(serverRunning) {
                    try {
                        selector.selectNow();
                        Iterator it;
                        synchronized(playersToRegisterToWrite) {
                            it = playersToRegisterToWrite.iterator();
                            while(it.hasNext()) {
                                Player player = (Player)it.next();
                                it.remove();
                                player.serverCon.configureBlocking(false);
                                player.serverCon.register(selector , SelectionKey.OP_WRITE , player);
                        Set keys = selector.selectedKeys() {
                        it = keys.iterator();
                        while(it.hasNext()) {
                            SelectionKey key = (SelectionKey)it.next();
                            if(key.isAcceptable()) {
                                it.remove();
                                clientCon = clientConSsc.accept();
                                clientCon.configureBlocking(false);
                                clientCon.register(selector , SelectionKey.OP_READ);
                                continue;
                            if(key.isReadable()) {
                                it.remove();
                                key.cancel();
                                new RequestHandler(this , (SocketChannel)key.channel()).start();
                                continue;
                            if(key.isWritable()) {
                                if(key.attachment() != null ) {
                                    ServerAction action = null;
                                    synchronized(actionsToDo) {
                                        Iterator aIt = actionsToDo.iterator();
                                        while(aIt.hasNext()) {
                                            ServerAction temp = (ServerAction)aIt.next();
                                            if(temp.getPlayer().equals((Player)key.attachment())) {
                                                action = temp;
                                                aIt.remove();
                                                break;
                                    if(action != null) {
                                        key.channel().configureBlocking(false);
                                        it.remove();
                                        key.cancel();
                                        action.start();
                                continue;
                    } catch(Exception e) {
                        statusArea.append(e.toString() + "\n");
                        e.printStackTrace();
                        continue;
            } catch(ClosedChannelException e) {
                statusArea.append(e.toString() + "\n");
            } catch(IOException e) {
                statusArea.append(e.toString() + "\n");
                A part of server's RequestHandler's class' method run() - the method which handles requests triggered by client on first port:
    public void run() {
            boolean served = false;
                try {
                    channel.configureBlocking(true);
                    retryCount++;
                    retry = false;
                    String command = ns.readText(channel).trim();
                    ns.statusArea.append("ktos przesyla komende: " + command + "\n");
                    if(command != null && !command.equals("ERROR")) {
                        String[] cmd = command.split("�");
                        ns.statusArea.append("komenda: " + cmd[0] + "\n");
                        if(cmd[0].equals("CHAT")) {
                            if(cmd.length != 5) {
                                retry();
                            } else {
                                if(cmd[2].equals("NOGAME")) {      // jezeli nie ma okreslonej gry czyli rozsylamy do wszystkich
                                    for(int i = 0 ; i < ns.loggedPlayersListItems.size() ; i++) {
                                        Player current = (Player)ns.loggedPlayersListItems.get(i);
                                        if(current.state == Player.CHOOSING && !current.equals(new Player(Integer.parseInt(cmd[1]))))   // jezeli gracz jest w okienku wybierania gry to wysylamy mu broadcast
                                            ns.actionsToDo.add(new SendMsg(ns , current , "CHAT�" + cmd[1] + "�" + cmd[3] + "�" + cmd[4]));
                                } else {
                                    Game game = (Game)ns.gamesListItems.get(ns.gamesListItems.indexOf(new Game(Integer.parseInt(cmd[2]))));
                                    for(int i = 0 ; i < game.players.size() ; i++) {
                                        Player current = (Player)game.players.get(i);
                                        if(!current.equals(new Player(Integer.parseInt(cmd[1]))))
                                            ns.actionsToDo.add(new SendMsg(ns , current , "CHAT�" + cmd[1] + "�" + cmd[3] + "�" + cmd[4]));
                                served = true;
                        } else if(cmd[0].equals("GETGAMEINFO")) {
                            if(cmd.length != 3)
                                retry();
                            else {
                                int gameID = Integer.parseInt(cmd[2]);
                                ns.statusArea.append("poproszono o informacje o grze nr: " + gameID + "\n");
                                Game checkedGame = new Game(gameID);
                                if(ns.gamesListItems.contains(checkedGame)) {
                                    Game game = (Game)ns.gamesListItems.get(ns.gamesListItems.indexOf(checkedGame));
                                    channel.configureBlocking(true);
                                    ObjectOutputStream oos = new ObjectOutputStream(channel.socket().getOutputStream());
                                    oos.writeObject(game);
                                    oos.writeObject(game.players);
                                    oos.flush();
                                    ns.statusArea.append("wyslano informacje o grze nr: " + gameID + "\n");
                                } else {
                                    ns.statusArea.append("brak gry o nr: " + gameID + "\n");
                                served = true;
                } catch(IOException e) {
                    e.printStackTrace();
            if(!served) {
                ns.findAndDisconnectPlayer(channel);
            try {
                channel.close();
            } catch(IOException e) {
                e.printStackTrace();
        }An example of ServerAction's subclass - the class which triggers server commands to client on second port:
    class UpdateLoggedPlayersList extends ServerAction {
        public UpdateLoggedPlayersList(NeuroServer ns , Player player) {
            super(ns , player);
        public void run() {
            try {
                serverCon.configureBlocking(true);
                ns.sendText("UPDATELOGGEDPLAYERSLIST" , serverCon);
                if(ns.readText(serverCon).equals("OK")) {
                    ObjectOutputStream oos = new ObjectOutputStream(serverCon.socket().getOutputStream());
                    oos.writeObject(ns.loggedPlayersListItems);
                    oos.flush();
                synchronized(ns.playersToRegisterToWrite) {
                     ns.playersToRegisterToWrite.add(player);
            } catch(IOException e) {
                e.printStackTrace();
    }A part of client's CmdHandler's class' method run() - the method which handles commands triggered by server:
    public void run() {
        try {
            while(works) {
                String command = nc.readText(nc.serverCon);
                System.out.println("Server przesyla komende: " + command + "\n");
                String[] cmd = command.split("�");
                if(cmd[0] != null && !cmd[0].equals("ERROR")) {
                    if(cmd[0].equals("CHAT")) {
                        if(nc.chooseGameDialog != null && nc.chooseGameDialog.isVisible()) {     // jezeli na wybieraniu gry
                            newChatEntry(cmd[2] , null , cmd[3] , nc.chooseGameDialog.chatPane);
                        } else if(nc.readyDialog != null && nc.readyDialog.isVisible()) {  // jesli na przygotowywaniu
                            Player sender = (Player)nc.actGame.players.get(nc.actGame.players.indexOf(new Player(Integer.parseInt(cmd[1]))));
                            newChatEntry(cmd[2] , sender.fraction , cmd[3] , nc.readyDialog.chatPane);
                        } else if(nc.ng != null) {                   // jesli w grze
                            Player sender = (Player)nc.actGame.players.get(nc.actGame.players.indexOf(new Player(Integer.parseInt(cmd[1]))));
                            newChatEntry(cmd[2] , sender.fraction , cmd[3] , nc.ng.inGameChatPane);
                    } else if(cmd[0].equals("UPDATELOGGEDPLAYERSLIST")) {
                        nc.sendText("OK" , nc.serverCon , false);
                        nc.serverCon.configureBlocking(true);
                        ObjectInputStream ois = new ObjectInputStream(nc.serverCon.socket().getInputStream());
                        DefaultListModel players = (DefaultListModel)ois.readObject();
                        nc.chooseGameDialog.updateLoggedPlayersList(players);
        } catch(IndexOutOfBoundsException e) {
            System.out.println(e);
        } catch(IOException e) {
            System.out.println(e);
        } catch(ClassNotFoundException e) {
            System.out.println(e);
    }And two methods I used in codes above: sendText(String text , SocketChannel sc) and readText(SocketChannel sc) - they are my "utility" methods, which I use to send and receive Strings through specified SocketChannels.
    boolean sendText(String text , SocketChannel sc) {
        ByteBuffer bbuf = ByteBuffer.allocate(BSIZE);
        boolean sendRetry;
        boolean sent = false;
        do {
            sendRetry = false;
            try {
                StringBuffer cmd = new StringBuffer();
                cmd.setLength(0);
                if(text.length()+4 < 100)
                    cmd.append("0");
                if(text.length()+4 < 10)
                    cmd.append("0");
                cmd.append(Integer.toString(text.length()+4) + "�");
                cmd.append(text);
                cmd.append("\n");
                bbuf = charset.encode(CharBuffer.wrap(cmd));
                sc.write(bbuf);
                bbuf.clear();
                int n = sc.read(bbuf);
                if(n == 1) {
                    bbuf.flip();
                    Byte re = bbuf.get();
                    if(re == 1) {
                        sendRetry = true;
                    } else {
                        sent = true;
            } catch(Exception e) {
                findAndDisconnectPlayer(sc);
                try {
                    sc.close();
                } catch(IOException f) {
                    f.printStackTrace();
                return false;
        } while(!sent && sendRetry);
        return true;
    String readText(SocketChannel sc) {
        ByteBuffer bbuf = ByteBuffer.allocate(BSIZE);
        int readRetryCount = -1;
        boolean readRetry;
        do {
            readRetry = false;
            readRetryCount++;
            StringBuffer cmd = new StringBuffer();
            cmd.setLength(0);
            bbuf.clear();
            try {
                readLoop:
                while(true) {
                    int n = sc.read(bbuf);
                    if(n > 0) {
                        bbuf.flip();
                        CharBuffer cbuf = charset.decode(bbuf);
                        while(cbuf.hasRemaining()) {
                            char c = cbuf.get();
                            if(c == '\r' || c == '\n') break readLoop;
                            cmd.append(c);
                    } else break;
                statusArea.append(Thread.currentThread().getId() + " readText() odczytuje: " + cmd.toString() + "\n");
                if(cmd.length() < 3 || Integer.parseInt(cmd.substring(0 , 3)) != cmd.length()) {
                    sc.write(ByteBuffer.wrap(new byte[] {1}));
                    readRetry = true;
                } else {
                    sc.write(ByteBuffer.wrap(new byte[] {0}));    // length OK
                    return cmd.toString().substring(4 , cmd.toString().length());
            } catch(Exception e) {
                findAndDisconnectPlayer(sc);
                try {
                    sc.close();
                } catch(IOException f) {
                    f.printStackTrace();
                return "ERROR";
        } while(readRetry && readRetryCount < 3);
        findAndDisconnectPlayer(sc);
        try {
            sc.close();
        } catch(IOException e) {
            e.printStackTrace();
        return "ERROR";
    }Edited by: Kakalec on Jul 23, 2008 11:04 AM

    You seem to be using a horrendous mixture of PrintWriters, BufferedReaders, ObjectOutputStreams, and no doubt ObjectInputStreams. You can't do that.
    Some rules about this:
    (a) Whenever you use a stream or reader or writer on a socket, you must allocate it once for the life of the socket, not every time you want to do an I/O.
    There are many reasons for this including losing buffered data in the old stream and auto-closure of the socket on garbage-collection of the old stream.
    (b) You can't mix stream types on the same socket. (i) If you're writing objects, use an ObjectOutputStream, you must read with an ObjectInputStream, and you can't read or write anything that isn't supported by the API of ObjectOutputStream. (ii) If you're writing lines, use a BufferedWriter and a BufferedReader at the other end. If you're writing characters, use a Writer and a Reader. (iii) If you're writing primitive data or UTF strings, use a DataOutputStream and a DataInputStream. (iv) If you're writing bytes, use DataOutputStream and a DataInputStream or an OutputStream and an InputStream. You can't mix (i), (ii), (iii), and (iv).
    (c) Don't use PrintWriter or PrintStream over the network. They swallow exceptions that you need to know about. They are for writing to the console, or log files, where you don't really care about exceptions.
    (d) Call flush() before reading.
    (e) Always close the 'outermost' output stream or writer of a socket, never the input stream or the socket itself. Closing any of these closes the socket and therefore makes the other stream unusable, but only closing the output stream/writer will flush it.

  • Write data to PLC

    i would like some help in writing characters/integers to a PLC. Allen Bradley SLC-500.

    Take a look at the documents below:
    Notes on Allen Bradley PLC Addressing
    Allen-Bradley PLC Addressing
    Allen Bradley SLC500 PLCs in Lookout
    Where can I Find Drivers for Communicating to PLCs, RTUs, and Other Industrial Hardware?
    The Lookout AB_SLC500 driver object does not actually support ethernet communication.
    The protocols supported by this object driver are listed in the help of the object and ethernet is not one of the available options. Since the AB_SLC500 object uses the same configuration window as the AB_PL5 object, it is possible to select Ethernet for the Interface field and PLC500 for the PLC model, yet this is not a supported combination. However, there have been developer's exchange posts from costumers who have successfully establish communication through ethernet to the SLC500 series PLC using the AB_SLC500, but this is not supported by National Instruments and is something to try at your own risk.
    Zvezdana S.
    National Instruments

  • Working with scaned images

    Hi only just started using illistrator so COMPLETElY new to this.
    I have a scanned image of my speedomiter that i want to work on in illistrator. obviously the scaned image is not perfect so i want to pick out all the speed gradations and tick marks and numbers and any other symbols on the scan so i can seperat them onto different layers and correct them, i can then print each layer out and build my guage face.
    i have worked out how to edit seperate layers, but is there an easy way to pic out all the objects i want or do i have use the pen tool on every thing i want to create the objects.
    many thanks.

    Is this perchance for a motorcycle? (Many models are notorious for speedo error.) I just built a corrected face for my DL1000 Suzuki, thusly:
    1. Import the scan into Illustrator. Place it on its own locked Layer. See online help about Template Layers.
    2. Create another Layer to draw on.
    See online help about Text On A Path. Assuming a circular guage, you can create your tick marks by:
    1. Draw a circle.
    2. Scissor: Cut the circle where it corresponds to the zero of the guage.
    3. PathType tool: Click on the cut circle to make it a PathType object.
    4. Type "pipe" characters (vertical bar; shift backslash) for the tick marks. Set paragraph alignment to Left, and justification to force justify (Justify All Lines).
    5. Drag the right end handle of the text to adjust its overall span around the circle. The tick marks will automatically space uniformly.
    Use individual PointType objects for the major tick mark labels.
    Again, best method depends on the shape and design of the guage.
    JET

Maybe you are looking for

  • How to track how long a program method takes to execute?

    So i am writing a radix sort in java and i want to see how long it takes to run. I was wondering how i would get the exact time that a method would take? Calendar cal = new GregorianCalendar();           int ms = cal.get(Calendar.MILLISECOND); I am n

  • How to fetch Errors in Workflow E-Mail

    Hi All :-) Just a short Question. We´re using OWB 10.1.0.4.0 and Workflow 2.6.x. Now i try to use the E-Meil Activity in a Workflow. Everything works fine, Mails delivered correct. So far so good... Now i want to fetch the evantually appearing Errors

  • After Finish PO Sened Automatically To The Dealer ?

    Dear All, Kindly if possible made button on the PO model sent PO directly to the dealer using Mail or Fax ? And after do this modification for model and make customization report then i want to updated system ; im loss this custom work for the model

  • How can I test (Abap) a session is from type RFC

    Hi , How can I test (Abap) a session is from type RFC ? Field in SY tables ?

  • Execution Results Not Showing...

    Hi, I am using Oracle Ware house Builder 10 g. In this tool in control Center Manager When i execute any maps i am able to see all the execution details. But Now i dont able to see the execution & Job Details For a Particular map..what to do???? Is t