Making space for string (character) in Java

A permutation is a function. In this particulate exercise, the function is certain space separation of an adjacent letter. Here is an example for the space is 2: After the first letter A, skip 2 spaces and arrive at D, skip another 2 space to arrive at G, so original ABC maps to adg.
ABCDEFGHIJKLMNOPQRSTUVWXYZ
maps to (with skip of 2 space):
adgjmpsvybehknqtwzcfilorux
You need to have a user input for the skip space, similar to the lab 1. Warning: Because there are 26 characters in the English alphabetic, if user enters an even number, you need to consider add one every time it passes the Z letter. Please help me to solve this problem.

Try using this code segment:
String abcString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
StringBuffer tempBuffer = new StringBuffer();
StringBuffer outBuffer = new StringBuffer();
tempBuffer.append(abcString);
i = 0;
while(i < abcString.length())
outBuffer.append(tempBuffer.charAt(i));
i+=2;
tempBuffer.setLength(0);
All you really need to do is change what you're adding to I every time you go through the loop, make it user input. This is simply an example of how to do it.
-Jason Thomas.

Similar Messages

  • Making space for multiple computers

    I have a year or so's worth of backups of my computer & my daughter's computer on my TC. My husband recently got a mac, and we want to back up his computer on the TC as well. However, when I turned TC on for him, he got a message saying that there is not enough space for his stuff. I would like to delete a few of the old backups we don't need to make room for his stuff, but I can't figure out how to do it. Do I need to delete the entire TC and then back up all three computers from scratch again? Thanks.

    Do I need to delete the entire TC and then back up all three computers from scratch again? Thanks.
    If you don't really need all the backups of how your other computers looked months ago and would not mind start a new set up backups again for each computer including your new Mac, your simplest and best option would be to erase the TC drive and start over again with Time Machine backups for each computer.
    Next best option would be to add more disk space with another drive and back up the new Mac to that drive.
    Post back if you need instructions on how to erase the TC drive.

  • Making space for Time Machine backup

    I am trying to backup my Macbook pro.  I have a 500gb drive with 190gb free space.  I have a 500gb external HD that I use for my Time Machine backups. 
    Shouldn't time machine automatically delete the old backup to make room or do I have to manually delete something?
    Thanks,
    Paul

    See the pink box at http://pondini.org/TM/C4.html

  • Help in getting making space for startup disk.

    When I open up a user file on my Mac mini, nothing comes up except a background and the mouse arrow. I need to make more space on my startup disk by deleting files. I can't do that because the users won't open up properly.

    Hi,
    You can create Perfmon data collectors with proper perfmon counters related to CPU. Memory and Disk utilization. The data collector can be configured to store the data in SQL Server. This stored perfmon data can be queried from reporting service reports
    to get a graphical representation. These reports can be subscribed so that the graphical reports can get mailed automatically at a specific time.
    Thanks and Regards Alankar Chakravorty MCITP Database Administrator SQL Server 2008 MCITP Database Administrator SQL Server 2005

  • Java 1.4.1 - Could not reserve space for object heap - need help

    I know this problem has been posted before, but I thought this was fixed in release 1.3. I'm using Windows XP/Professional and do the following:
    C:java -Xmx2g
    Error occured during initialization of VM
    Could not reserve space for object heap
    C:java -version
    java version "1.4.1_02"My computer system has 1 GB of RAM and a 2 GB pagefile, expandable to 3.5 GB. I can get going with -verbose:gc -Xmx1600m -Xms200m, but the GC only gets to about 1 GB before I get an out of memory exception, not even close to 1.6 GB as specified.
    I'd really appreciate it if anyone can shed some light on this behavior.
    Cheers, Eric

    Hmm.
    I tried a mini no-operation application with jdk1.3.1 on Linux. It run okay like this:
    $ java -Xmx1934M u
    $ echo $?
    0
    $ java -version
    java version "1.3.1_07"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_07-b02)
    Java HotSpot(TM) Client VM (build 1.3.1_07-b02, mixed mode)
    $ cat u.java
    class u {
    public static void main(String a[]) {
    $This however fails miserably:
    $ java -Xmx1935M u
    Unexpected Signal : 11 occurred at PC=0x401a0cb7
    Function name=start_thread__2osP6Thread
    Library=/usr/lib/jdk1.3.1_07/jre/lib/i386/client/libjvm.so
    Current Java thread:
    Dynamic libraries:
    08048000-0804c000 r-xp 00000000 03:08 174723     /usr/lib/jdk1.3.1_07/bin/i386/native_threads/java
    0804c000-0804d000 rw-p 00003000 03:08 174723     /usr/lib/jdk1.3.1_07/bin/i386/native_threads/java
    40000000-40012000 r-xp 00000000 03:08 20686      /lib/ld-2.2.5.so
    40012000-40013000 rw-p 00011000 03:08 20686      /lib/ld-2.2.5.so
    ...This looks familiar:
    $ java -Xmx2000m u
    Error occurred during initialization of VM
    Could not reserve enough space for object heap

  • Is it possible to search for strings containing spaces and special characters?

    In our RoboHelp project, there are figures with text labels such as Figure 1, Figure 3-2, etc.
    When I search for "Figure 3" I get all pages containing "Figure" and "3", even if I surround it in quotes.  Similarly, searching for "3-2" treats the '-' character as a space and searches for all pages containing '3' or '2'.
    Is there a way to search for strings containing spaces and special characters?

    In that case I think the answer is no if you are using the standard search engine. However I believe that Zoom Search does allow this type of searching. Check out this link for further information.
    http://www.grainge.org/pages/authoring/zoomsearch/zoomsearch.htm
      The RoboColum(n)
      @robocolumn
      Colum McAndrew

  • Problem with Java Memory "Could not reserve enough space for object heap"

    Hi gurus,
    I am not an expert with Java´s configuration, and I have a situation that I don´t understand. First of all, I am working at Centos 6.2 with jdk_1.6 and Tomcat 7.
    The problem is...
    - If I run Tomcat with JAVA_OPTS="-Xmx128m"* (at catalina.sh) all works fine.
    - If I run Tomcat with JAVA_OPTS="-Xmx512m"* (at catalina.sh) an error appears:
    Error occurred during initialization of VM
    Could not reserve enough space for object heap
    Could not create the Java virtual machine.
    This appear when I run java -version or when I try to stop Tomcat, and the Tomcat isn´t able to stop.
    The strange thing is that my server has more than 200M free in physical memory. So, why Tomcat isn´t able to stop? and Why Java doesn´t use the free memory in my server?
    Thanks in advanced.

    Hello EJP, thanks for your answer.
    I have explained bad.
    The server has 703M free when Tomcat is stopped. I had mentioned that my server has more than 200M free in physical memory when Tomcat is running with JAVA_OPTS="-Xmx512m", so I don´t understand why these errors appear.
    Do you understand me?
    Recently I have checked the swap memory, and it is disabled. In spite of swap memory is disabled I think java wouldn´t need this memory because it has free physical memory
    Thanks again.

  • Hi all! What is the best way to create the correct space for baseball jersey names and numbers? along with making sure they are the right size for large printing.

    What is the best way to create the correct space for baseball jersey names and numbers? along with making sure they are the right size for large printing.

    Buying more hard drive space is a very valid option, here.  Editing takes up lots of room, you should never discount the idea of adding more when you need it.
    Another possibility is exporting to MXF OP1a using the AVC-I codec.  It's not lossless, but it is Master quality.  Plus the file size is a LOT smaller, so it may suit your needs.

  • Spaces for Zeroes

    Newbie alert!
    I have a simple table with 4 elements per line comprising
    A: description B: value C: quantity D: (B * C)
    For each line A and B have pre-set values... I enter a quantity in C and it calculates a value in D
    When C (quantity) is Zero I want a 'space' in both C and D.
    This works fine until I actually enter a value in C, then change my mind and enter a space...
    D assumes C has a value of 1 (??)
    I'm looking for a function that says something like:
    If either B or C = 'space' then D = 'space' else D=B*C
    I can see functions that look as if they might work but I can't figure it out
    If someone can point me in the right direction i'd much appreciate it.
    Thanks

    Thanks for the response Jerry..
    I'm trying to understand why you would enter a space for zero.
    Yep, when i read my explanation back it sounded more complex than it really is
    I'm creating a 'picking' document that will double as an invoice - having zeroes in the quantity field doesn't make quantities >0 stand out - the finished form needs to be easily scanned so that the items that need to be selected can be quickly identified.
    You can Conditionally Format the cells in D such that when the result is zero the font the color will be that of the fill, making the text invisible. You can also apply a test to see what is in B and/or C and set the result to a space, some other non-visible character or a null string.
    I'm going to try this route... didn't realise you could change text colour and stuff, that opens possibilities... sounds like i could change the fill colour on lines with values in so that they really stood out from the 'unselected' lines... will give it a look - cheers

  • How to use the scanner class to ask for a character?

    Hey guys, this is my assignment:
    Ask the user for a single letter and a sentence, and print out the
    number of times that letter shows up in the sentence.
    Please tell me how to scan for a character. I tried this:
    import java.util.Scanner;
    public class Frequencies
        public static final void main(String[] args)
            Scanner scanner = new Scanner(System.in);
            Scanner scan = new Scanner(System.in);
            System.out.println("Enter a sentence");
            String x = scanner.next();
            System.out.println("Enter a letter to look for");
            String y = scan.next();
            char z = y.charAt(0);
            int chara = 0;
            for(int i = 0; i<x.length(); i++){
                    if(z==y.charAt(i)){
                            chara = chara++;
            System.out.println("There are " + chara + " " + z + "s in the sentence");
    }and got the error after Running (not compiling):
    Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 1
            at java.lang.String.charAt(String.java:687)
            at Frequencies.main(Frequencies.java:16)I thought this meant that I was asking for the character in postition 1 of string y, but in my code I wrote position 0
    when I tried inserting words in the character place (just to see what happened, not expecting functionallity, I got
    Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: [NUMBER OF CHARACTERS]
            at java.lang.String.charAt(String.java:687)
            at Frequencies.main(Frequencies.java:16)Please help.
    The assignment isn't due nor graded, this is just killing me lol.
    Thanks in advance
    Edited by: Sevan on Oct 18, 2008 4:40 PM

    jverd wrote:
    Skydev2u wrote:
    I've used this method for a while now and it gets the job done.
    import java.util.Scanner;
    public class ReadInput {
    public static void main(String[] args) {
    Scanner UserInput = new Scanner(System.in);
    char letter = UserInput.findWithinHorizon(".", 0).charAt(0);
    I know you're trying to help, but this isn't really doing it. It does nothing to address the source of the OP's problem. The way he's doing it now is almost right. He just needs to do a tiny bit of detective work to fix a small bug. Tossing off a totally different approach, with no explanation, is not particularly helpful.Your right jverd I skimmed the OP's problem too quick;y and in tern didn't understand it fully. After reading the post thoroughly I saw that the problem can be solved by taking the sentence the user enters and then converting it into a array of characters. Then searching for the specific letter the user enters is achieved by comparing it to each individual element of the char array. Then incrementing a counter variable each time a match is made. I hope this example code solve your problem.
    * @author skydev
    import java.util.Scanner;
    public class SentenceReader {
        public static void main(String[] args) {
            int counter = 0; //Amount of time the letter appears in the sentence
            char letter;    //Letter the user search for
            char[] sentenceArray; //char array to hold the elements of the string the user inputs
            String sentence; //sentence the user inputs
            Scanner UserInput = new Scanner(System.in);
            System.out.println("Please enter a sentence! ");
            sentence = UserInput.nextLine();
            sentenceArray = sentence.toCharArray(); //splits up the users sentence into a array of char
            System.out.println("Please enter a letter to search for ");
            letter = UserInput.findWithinHorizon(".", 0).charAt(0);
             for(int i = 0; i < sentence.length(); i++){
                    if(letter == sentenceArray){ //search to see if the letter of interest equals to each char (letter) of the array
    counter++; //increments the amount of time the letter appears, set to 0 by default
    System.out.println("The letter appeared " + counter + " times in the sentence"); //Displays the result :) I love programming

  • How to know they is space or carrier return when java read a text file.

    Hi,
    Please help.
    How to know they is space or carrier return when java read a text file.
    The reason is that. I want to use java for loop to read each part of value. for example: first part is the items name. After the space (I need to tell java when this is a space here and its need to skip) , following by the items prices in double value and space again (need to skip also) and etc.
    item name1
    item name2
    item name3
    item name4
    item name5
    <--- here is the space to skip and another loop to read following items prices
    item price1
    item price2
    item price3
    item price4
    item price5
    <--- here is another spcae again. and so on
    thank in advance!

    You can check to see if the sting you read in is just nothing, depending on how you're reading it in:
    if((str = inStream.readLine().trim().equals("")))
    // skip and get ready for the next section
    else
    // handle the next item
    The trim() method gets rid of all leading and trailing spaces and I'm assuming you're using a stream that can use the readLine() method that returns a String.
    I hope this is clear. Let me know if it isn't, I'll try and word it different, or post how you're reading the values in if you need more help.

  • Handling Character Entities - Java Mapping Issue

    Hi Experts,
        I need to replace the character entities in my input XML. But, the problem is the java mapping I've written isn't replacing  the character entities as expected.  For example if my input XML  contains <NAME>&><XYZ</NAME>, then the ouput is <NAME>&amp:&gt:<0001&lt:/NAME>, whereas it should be <NAME>&amp:&gt:&lt:0001</NAME>.
    Note: I've used : instead of ; just to show it properly SDN.
    Can any of you share the code for the same if you've used it already?
    Thanks a lot in advance.
    Regards,
    Hussain.

    Hi Pooja,
        Thanks for your prompt reply.
    Are you trying to use the java mapping just to handle the character entities or your interface itself only has a java mapping?
                   - I'm using Java Mapping just to handle the character entities. Say my input XML looks like
    <?xml version="1.0" encoding="UTF-8"?>
    <resultset>
    <row>
    <ID>&<1</ID>
    <MESSAGE><![CDATA[<?xml version="1.0" encoding="UTF-8" ?><LGORT>&<0001</LGORT>]]></MESSAGE>
    </row>
    </resultset>
    I need to replace &< in <ID> to &amp:&lt: and similarly for CDATA <LGORT>&amp:&lt:0001</LGORT> before I process it in XI. In my java mapping I read the whole XML as string (line by line as mentioned below) and try to replace the character entities using some logic, which isn't working properly.
    StringBuffer buffer = new StringBuffer();
    BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
    for (String lineRead = reader.readLine(); lineRead != null; lineRead = reader.readLine()) {
           buffer.append(lineRead);
    I've also checked the thread mentioned by Srinivas. But, StringEscapeUtils.escapeXml() would replace all the character entities like &lt:?XML... , which would result in an invalid xml...
    Please suggest.
    Thanks,
    Hussain.

  • Program for string comparision in ABAP

    Hi,
    I require a program in abap for string comparision

    Comparing Strings
    Similarly to the special statements for processing strings, there are special comparisons that you can apply to strings with types C, D, N, and T. You can use the following operators:
    <operator>
    Meaning
    CO
    Contains Only
    CN
    Contains Not only
    CA
    Contains Any
    NA
    contains Not Any
    CS
    Contains String
    NS
    contains No String
    CP
    Contains Pattern
    NP
    contains No Pattern
    There are no conversions with these comparisons. Instead, the system compares the characters of the string. The operators have the following functions:
    CO (Contains Only)
    The logical expression
    <f1> CO <f2>
    is true if <f1> contains only characters from <f2>. The comparison is case-sensitive. Trailing blanks are included. If the comparison is true, the system field SY-FDPOS contains the length of <f1>. If it is false, SY-FDPOS contains the offset of the first character of <f1> that does not occur in <f2> .
    CN (Contains Not only)
    The logical expression
    <f1> CN <f2>
    is true if <f1> does also contains characters other than those in <f2>. The comparison is case-sensitive. Trailing blanks are included. If the comparison is true, the system field SY-FDPOS contains the offset of the first character of <f1> that does not also occur in <f2>. If it is false, SY-FDPOS contains the length of <f1>.
    CA (Contains Any)
    The logical expression
    <f1> CA <f2>
    is true if <f1> contains at least one character from <f2>. The comparison is case-sensitive. If the comparison is true, the system field SY-FDPOS contains the offset of the first character of <f1> that also occurs in <f2> . If it is false, SY-FDPOS contains the length of <f1>.
    NA (contains Not Any)
    The logical expression
    <f1> NA <f2>
    is true if <f1> does not contain any character from <f2>. The comparison is case-sensitive. If the comparison is true, the system field SY-FDPOS contains the length of <f1>. If it is false, SY-FDPOS contains the offset of the first character of <f1> that occurs in <f2> .
    CS (Contains String)
    The logical expression
    <f1> CS <f2>
    is true if <f1> contains the string <f2>. Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true, the system field SY-FDPOS contains the offset of <f2> in <f1> . If it is false, SY-FDPOS contains the length of <f1>.
    NS (contains No String)
    The logical expression
    <f1> NS <f2>
    is true if <f1> does not contain the string <f2>. Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true, the system field SY-FDPOS contains the length of <f1>. If it is false, SY-FDPOS contains the offset of <f2> in <f1> .
    CP (Contains Pattern)
    The logical expression
    <f1> CP <f2>
    is true if <f1> contains the pattern <f2>. If <f2> is of type C, you can use the following wildcards in <f2>:
    for any character string *
    for any single character +
    Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true, the system field SY-FDPOS contains the offset of <f2> in <f1> . If it is false, SY-FDPOS contains the length of <f1>.
    If you want to perform a comparison on a particular character in <f2>, place the escape character # in front of it. You can use the escape character # to specify
    characters in upper and lower case
    the wildcard character "" (enter # )
    the wildcard character "" (enter # )
    the escape symbol itself (enter ## )
    blanks at the end of a string (enter #___ )
    NP (contains No Pattern)
    The logical expression
    <f1> NP <f2>
    is true if <f1> does not contain the pattern <f2>. In <f2>, you can use the same wildcards and escape character as for the operator CP.
    Trailing spaces are ignored and the comparison is not case-sensitive. If the comparison is true, the system field SY-FDPOS contains the length of <f1>. If it is false, SY-FDPOS contains the offset of <f2> in <f1> .
    DATA: F1(5) TYPE C VALUE <f1>,
          F2(5) TYPE C VALUE <f2>.
    IF F1 <operator> F2.
       WRITE: / 'Comparison true, SY-FDPOS=', SY-FDPOS.
    ELSE.
       WRITE: / 'Comparison false, SY-FDPOS=', SY-FDPOS.
    ENDIF.
    The following table shows the results of executing this program, depending on which operators and values of F1 and F2.
    <f1>
    <operator>
    <f2>
    Result
    SY-FDPOS
    'BD '
    CO
    'ABCD '
    true
    5
    'BD '
    CO
    'ABCDE'
    false
    2
    'ABC12'
    CN
    'ABCD '
    true
    3
    'ABABC'
    CN
    'ABCD '
    false
    5
    'ABcde'
    CA
    'Bd '
    true
    1
    'ABcde'
    CA
    'bD '
    false
    5
    'ABAB '
    NA
    'AB '
    false
    0
    'ababa'
    NA
    'AB '
    true
    5
    'ABcde'
    CS
    'bC '
    true
    1
    'ABcde'
    CS
    'ce '
    false
    5
    'ABcde'
    NS
    'bC '
    false
    1
    'ABcde'
    NS
    'ce '
    true
    5
    'ABcde'
    CP
    'b'
    true
    1
    'ABcde'
    CP
    '#b'
    false
    5
    'ABcde'
    NP
    'b'
    false
    1
    'ABcde'
    NP
    '#b'
    true
    5
    goto sap library if intsalled in ur system and check the above one....

  • Can u suggest me books for my course in java

    Hi guys,
    i m a student of Computer Science can any of u people tell me the best suitable books or tutorials for me course in java i don't have any support from my college's side as its an elective n no prescribed books as such
    the Syllabus is as under:
    Java Programming_
    Object oriented programming revisited, JDK, Java Virtual machine-Platform independent-portability-scalability Operators and expressions-decision making ,branching, looping, Classes, Objects and methods, Arrays Strings and Vectors, Interfaces, Packages, Multi-Threading, managing errors and exceptions, Applet programming, Managing files and streams
    Java Technology for Active Web Documents*
    An Early Form of Continuous Update, Active Documents and Server Overhead, Active Document Representation and Translation, Java Technology, the Java Run-Time Environment, The Java Library
    A Graphics Toolkit, Using Java Graphics on a Particular Computer, Java Interpreters and Browsers
    Compiling a Java Program, Invoking an Applet, Example of Interaction with a Browser
    __RPC and Middleware__
    Programming Clients and Servers, Remote Procedure Call Paradigm, RPC Paradigm, Communication Stubs, External Data Representation, Middleware and Object-Oriented Middleware
    Network Management (SNMP)*
    Managing an Internet, The Danger of Hidden Features, Network Management Software, Clients, Servers, Managers and Agents, Simple Network Management Protocol, Fetch-Store Paradigm, The MIP and Object Names, The Variety of MIB Variables, MIB variables that correspond to arrays
    Java technologies*
    Graphics, JFC-JAVA foundation classes, swing, images, java 2d graphics, internationalization, Communication and Networking, TCP Sockets, UDP Sockets, java.net, java security, Object serialization, Remote method serialization, JDBC: Java Data Base Connectivity, Java beans, Java interface to CORBA, JAVA- COM Integration, Java Media Framework, commerce and java wallet, Data structures and java utilities, JavaScript, Servelets
    Thanks in Advance
    Regards
    Abhay Sagar

    Take a look through these and see which ones work for you.
    Sun's [basic Java tutorial|http://java.sun.com/docs/books/tutorial/]
    Sun's [New To Java Center|http://java.sun.com/learning/new2java/index.html].Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
    [http://javaalmanac.com|http://javaalmanac.com]. A couple dozen code examples that supplement [The Java Developers Almanac|http://www.amazon.com/exec/obidos/tg/detail/-/0201752808?v=glance].
    jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
    JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
    Bruce Eckel's [Thinking in Java|http://mindview.net/Books/DownloadSites] (Available online.)
    Joshua Bloch's [Effective Java|http://www.amazon.com/Effective-Java-2nd-Joshua-Bloch/dp/0321356683/ref=pd_bbs_1?ie=UTF8&s=books&qid=1214349768&sr=8-1]
    Bert Bates and Kathy Sierra's [Head First Java|http://www.amazon.com/exec/obidos/tg/detail/-/0596004656?v=glance].
    James Gosling's [The Java Programming Language|http://www.bookpool.com/sm/0321349806].

  • BufferedReader Problem (inserting space after every character)

    (This is a message I sent to an Aglet forum, however I thought maybe someone here could help me with the BufferedReader problem...with the spacing...read below)
    -Blake
    ok here's what I'm attempting to do.
    I have a Master Aglet that creates a slave which is dispatched to a remote site. The Slave then opens a log file, reads it, and then is supposed to read the file line by line and send each line as a message back to the Master. As the master receives each line it appends the line to the window it created earlier.
    I don't know what the problem is...it won't display the log file in the master window.
    It does display each line on the console window.I added a println() function to make sure the String array was getting the information. There is a small problem with that as well because it inserts a space after EVERY character (BufferedReader problem??)...what is up with that? for example:
    If the log file looked like: This is a log file entry.
    the console looks like this when it is printed: T h i s i s a l o g f i l e e n t r y .
    .... I had done something in a similiar program...and it worked just fine. here's some source code:
    <b>Master:</b>
    else if (msg.sameKind("Log")) {
    try {
    //println for testing purposes
    System.out.println(msg.getArg());
    appendMessage(" " + msg.getArg() + "test \n");
    } catch (Exception e) {
    System.out.println(e.toString());
    <b>Slave: </b>
    File log = new File("C:\\Aglets2.0.2\\public\\WINDOWSUPDATE.log");
    FileReader fr = null;
    try{
    fr = new FileReader(log);
    } catch (FileNotFoundException e) {
    System.out.println(e);
    BufferedReader br = new BufferedReader(fr);
    //Get filename of log
    try {
    Message msg = new Message("FileName", log.getName());
    mProxy.sendOnewayMessage(msg);
    } catch (InvalidAgletException iae) {
    System.out.println(iae.toString());
    } catch (Exception e) {
    System.out.println(e.toString());
    //read each line of file and send back to Master as a message
    try{
    int i = 0;
    while ((s = br.readLine()) != null) {
    i++;
    count = i;
    for (int j = 0; j < count; j++)
    System.out.println(s[j]);
    //send message back to Master Aglet with log file information
    try {
    Message msg = new Message("Log", s[j]);
    mProxy.sendMessage(msg);
    } catch (InvalidAgletException iae) {
    System.out.println(iae.toString());
    } catch (Exception e) {
    System.out.println(e.toString());
    //close file reader
    fr.close();
    } catch (IOException e) {
    System.out.println(e.toString());
    }

    actually i did declare s, you just don't see it there because i only posted some of the code....
    I fixed the "spacey" problem by using a FileInputStream instead of a bufferedreader....
    like this (i'll post the whole code here:
    public class Slave extends BlindAglet {
        AgletProxy mProxy = null;
        boolean back = false;
            char[] c = new char[1000];
        BufferedReader br = null;
        int count;
        // Do some tasks when the aglet is created
        public void onCreation(Object init) {
            // Must make a note of the master here
            mProxy = (AgletProxy)init;       
            // Add our own listener and adapter
            addMobilityListener(
                new MobilityAdapter() {
                    // Using this as a safety check in case we get caught in a loop in the same host
                    public void onArrival(MobilityEvent event) {                   
                        try {
                            mProxy.sendMessage(new Message("NewSlaveProxy", getAgletContext().getAgletProxy(getAgletID())));                                                            
                        } catch (InvalidAgletException iae) {
                            System.out.println(iae);
                        } catch (NotHandledException ex) {
                            System.out.println(ex);
                        } catch (MessageException ex) {
                            System.out.println(ex);
                        //Are we back to origin?
                            if(back) {         
                                 back = false;     
                                try{
                                     FileWriter fw = new FileWriter("test.txt");                                                                  
                                 for (int i = 0; i < count; i += 2){ 
                                           fw.write(c);
                             fw.close();
                        } catch (IOException e) {
                                  System.out.println(e);
                                  dispose();
                             dispose();
    ); /* End of Adapter */
    public void run() {
         // Are we at home base?
    if (atHome()) {
    try {
    dispatch(new URL("atp://darklord:4434"));
    } catch (Exception e) {
    System.out.println(e.toString());
         try{
         File log = new File("C:\\Aglets2.0.2\\public\\WINDOWSUPDATE.log");
         FileInputStream f0 = new FileInputStream(log);
    //Get filename of log
    try {
         System.out.println(log.getName());
    Message msg = new Message("FileName", log.getName());
    mProxy.sendOnewayMessage(msg);
    } catch (InvalidAgletException iae) {
    System.out.println(iae.toString());
    } catch (Exception e) {
    System.out.println(e.toString());
              //read each line of file and send back to Master as a message
              try{               
         int size = f0.available();
         int i = 0;
         for (i = 0; i < size; i++) {
              c[i] = (char) f0.read();
    //send message back to Master Aglet with log file information
                             try {
                        Message msg = new Message("Log", c[i]);
                        mProxy.sendOnewayMessage(msg);
              } catch (InvalidAgletException iae) {
                             System.out.println(iae.toString());
                        } catch (Exception e) {
                             System.out.println(e.toString());
    count = i;
              } catch (IOException e) {
                   System.out.println(e.toString());
                   } catch (FileNotFoundException e) {
                   System.out.println(e);
         back = true;      
         returnHome();
    * Returns true if the current host is our origin
    public boolean atHome() {
    if (getAgletInfo().getOrigin().equals(getAgletContext().getHostingURL().toString()))
    return true;
    else
    return false;
    * Allows a slave to contact it's master and ask for a retraction.
    public void returnHome() {
    try {
    Message msg = new Message("RetractMe");
    msg.setArg("url", getAgletContext().getHostingURL());
    msg.setArg("id", getAgletID());
    mProxy.sendOnewayMessage(msg);
    } catch (InvalidAgletException iae) {
    System.out.println(iae.toString());
    } catch (Exception e) {
    System.out.println(e.toString());
    * Return a reference to our Master's proxy
    public AgletProxy getMasterProxy() {
    return mProxy;
    } /* End of Class

Maybe you are looking for