Can't figure out last part of a powershell script

Hey guys,
First time posting here. I have a powershell project for school that I'm trying to figure out. I don't have a lot of experience with powershell, but I've gotten most of my project done. I am having issues with this last part. Here is the part of the assignment
I can't seem to get working properly:
Process the items in the <localgroupManagement> node.
Find all non-domain controller computers in the domain
Add the domain global group specified in the <members><group> node(s) to each discovered computer’s local group specified by the
<name> node.  If the local group does not exist create it.
Here is the code I currently have:
param([string]$filename)
Function createOU($OU) {
    if ( !(Get-ADOrganizationalUnit -filter {name -eq $OU}) ) {
        Write-Host "Creating new OU: $OU"
        New-ADOrganizationalUnit -Name $OU -Path $ADDomainName
    else {
        Write-Host "OU already exists: $OU"
Function addUser($account, $fn, $ln, $desc, $pwd, $OU, $ADDomainName, $ADgroup) {
    if ( !(Get-ADUser -Filter {name -eq $account}) ) {        
        Write-Host "Adding user: $account"
        New-ADUser $account -GivenName $fn -Surname $ln -Description $desc -Enabled 1 `
        -DisplayName ($fn + " " + $ln)  -AccountPassword $pwd -ChangePasswordAtLogon $true `
        -Path "OU=$OU,$ADDomainName"
    else {
        Write-Host "User already exists: $account"
Function addGroup($ADgroup, $ADDomainName, $OU) {
    if ( !(Get-ADGroup -Filter{name -eq $ADgroup}) ) {          
        Write-Host "Adding group: $ADgroup"
        New-ADGroup -Name $ADgroup -GroupCategory Security `
        -GroupScope Global -Path "OU =$OU,$ADDomainName" 
    else {
        Write-Host "Group already exists: $ADgroup"
### MAIN PROGRAM
if( !$filename ) {
    # prompt the user to select a file to process
    [System.Reflection.Assembly]::LoadWithPartialName("system.windows.forms")
    $dialog = New-Object System.Windows.Forms.OpenFileDialog
    $dialog.Filter = "XML Files (*.xml)|*.xml|All Files(*.*)|*.*"
    $dialog.Title = "Select an XML file to import“
    $result = $dialog.showdialog()
    if ( $result -eq "ok" ){
        $filename = $dialog.Filename
$userfile = [xml](Get-Content $filename)
$ADDomainName = (Get-ADDomain).DistinguishedName
foreach( $user in $userfile.root.userManagement.user ) {
    $account = $user.account
    $fn = $user.firstname
    $ln = $user.lastname
    $desc = $user.description
    $pwd = ConvertTo-SecureString -AsPlainText $user.password -force
    $mgr = $user.manager
    $OU = $user.ou
    Write-Host
    Write-Host $account
    Write-Host $fn
    Write-Host $ln
    Write-Host $desc
    Write-Host $user.password
    Write-Host $mgr
    Write-Host $OU
    createOU $OU $ADDomainName
    foreach( $groupmem in $user.memberof.group ) {
        $ADgroup = $groupmem
        addGroup $ADgroup $ADDomainName $OU
        addUser $account $fn $ln $desc $pwd $OU $ADDomainName $ADgroup
        Add-ADGroupMember $ADgroup -Members $account      
#Local Management
$computers = Get-ADComputer -Filter * | where {-not($_.distinguishedname -like "*OU=Domain Controllers*")}| `
foreach{$_.name}
Write-Host "Computers that already exsist on the Network:"
foreach($computer in $computers) {
$DomainName =(Get-ADDomain).NetBIOSName
$localgroups = $userfile.root.localGroupManagement.localGroup
    foreach($lg in $localgroups.name) {
        try {   
            $newgrp = [adsi]::Exists("WinNT://$computer/$lg,group")
            if($newgrp -eq $true) {
                Write-Host "$lg Already Exists!"
            else {
           $ds=[adsi]("WinNT://$computer,computer")
           $group=$ds.create("group",$lg)
                $group.setinfo() 
        catch [Exception] {
write-host "Exception"
I have tried other methods, but this is the one I receive the least amount of errors on. The script starts to have issues here:   $newgrp = [adsi]::Exists("WinNT://$computer/$lg,group")
I have looked information up about WinNT Exists and it appears it has some issues. I have been trying to figure out how to add the domain groups to the local computer's groups. The tricky part is that the script has to run without knowing the computer's
name so it can run on any domain. If anyone could help me out with this last part I would be very grateful.

The script should be using WinNT to find computers on the domain and add domain group to each of those computers local group. I have provided portions of the xml file and instructions to help clarify.
Here is the portion of the xml file I'm having issues with
<localGroupManagement>
<localGroup>
<name>Power Users</name>
<members>
<group>Marx Brothers</group>
</members>
</localGroup>
<localGroup>
<name>Musicians</name>
<members>
<group>GGMusicians</group>
</members>
</localGroup>
</localGroupManagement>
</root>
Here is what the assignment is assuming.
Assumptions
The computer the script is running on will be in the domain that you wish to manage. 
The computer running the script will have the Active Directory PowerShell module installed.
The user running the script will have rights to do all required tasks

Similar Messages

  • TS1424 I purchased an album and all but one song downloaded, I can't figure out how to get that last song to download??

    I purchased an album and all but one song downloaded, I can't figure out how to get that last song to download??

    Hello Kathie1970,
    Thanks for using Apple Support Communities.
    For more information on this, take a look at:
    How to report an issue with your iTunes Store, App Store, Mac App Store, or iBooks Store purchase
    http://support.apple.com/kb/ht1933
    Best of luck,
    Mario

  • TS1702 I can not figure out where to go to report this but every since my last facebook update, facebook crashes everytime I open it (withing 30 sec) - using ITouch 4th Gen.

    I am not sure if this is where I go to report this, but I can't figure out where else to go. Ever since I downloaded the last App update for facebook, facebook crashes within 30 sec of opening - EVERY TIME!

    See:
    iOS: Troubleshooting applications purchased from the App Store
    Contact the developer/go to their support site if only one app.
    Restore from backup. See:
    iOS: How to back up              
    Restore to factory settings/new iPod

  • If my iPhone was stolen and wiped clean can I figure out the exact time it was wiped and the last GPS location before it was wiped?

    If my iPhone was stolen and wiped clean can I figure out the exact time it was wiped and the last GPS location before it was wiped?

    Sorry, no.

  • The last version of Firefox would go to a choice box when a new screen came up. I can't figure out how to get that feature back in Firefox 4

    For example. When checking spam in Gmail.....if I ask to delete all spam mail.....the cursor would automatically go to the box that pops up asking for confirmation. I can't figure out how to get that feature back. Otherwise everything works great!

    I have the same problem getting into Mozilla. Occasionally it comes up when I click on it, but most times it does not. The hour glass stays on for a couple of seconds, then goes off.

  • I can't figure out how to edit part of GTK theme.

    I'm attempting to heavily modify the Numix GTK theme on Cinnamon. There's just one thing I can't figure out where to edit.
    Here is a screenshot from Firefox showing a redish/orange highlight color:
    https://drive.google.com/file/d/0B4n4B8 … sp=sharing
    I want a different color. How can I change that?

    FYI, you can/should mark your thread as solved.
    Finally, when a solution is found, mark your thread as solved by editing the first post and prepending the tag [SOLVED] to the title in the "Subject" field.
    https://wiki.archlinux.org/index.php/Forum_Etiquette

  • If I open a photo in "preview", multiple photos open. I just want to open one, but can't figure out how to do it.

    I keep multiple photos in a desktop folder to be quickly accessed by using Preview. But when I try to open ONE photo, it opens multiple photos. Can't figure out how to display just the single one that I select.  OS 10.7.2

    This is the resume feature of Lion. The last state of the application is saved when quitting (i.e last pictures viewed in Preview, last videos viewed in Quicktime etc).
    You can switch it off for Preview by copy and pasting the following in to the terminal application
    defaults write com.apple.Preview NSQuitAlwaysKeepsWindows -bool false

  • I'm trying to connect a BlueTooth headset to my Mac Mini. I can discover it, but soon after discovery it disconnects. Can't figure out how to reconnect. My only option seems to be re-discovery

    I can discover the headset, but soon after discovery it disconnects. Haven't been able to figure out how to try to re-connect. And the help section titled "Use BlueTooth has absolutely no information on how to use it. All I can do is re-discover it. Every time I rediscover it, it disconnects shortly afterward. This headset works well with both my iPhone and iPad and has for quite some time. But it won't stay connected to my Mac.

    Tried with another headset that works fine with iPhone and iPad. An LG HBS700. Same problem. It connects for maybe 10 seconds and then disconnects. So it must be a problem on the Mac. But this Mini is out of warrentee so taking it into an Apple store to get it repaired isn't a good solution. Maybe as a last resort.
    Is there a way to select connect on the Mac? Everything else I've connected a BlueTooth device to has both a command for pairing and a command for connecting or reconnecting. I can't figure out how to select connect on the Mac.

  • How do i synch my pdf/books to my library. I was able to synch my ipod touch purchases by transferring them but can't figure out how to do my pdfs. Also why is my ipod picture greyed out-the one that lets my move the icons around.

    How do i synch my pdf/books to my Itunes  library. I was able to synch my ipod touch app purchases by transferring them but can't figure out how to do my pdfs. Also why is my ipod picture greyed out-the one that lets my move the icons around.
    I am afraid if i don't get the pdfs into my book library, i will lose them when i update to IOS 5-is that true?

    thank you-i have to check into the authorization and the account-i gave my husband my old ipod when i updated last year so both at one time have been on this computer but as it stands, it only comes up with my device when i plug into Itunes.
    i don't think i have any restrictions for installing apps although my normal way of doing it is to download from the ipod touch. i did find that all i had to do was right click on my device name and got the message to transfer my apps and then they showed up in my library. Also when i clicked the synch checkbox i was able to view the ipod touch picture without it being greyed out. after all that i was able toupdate to IOS 5 successfully except my videos and podcast, and pdfs  did not come over. This confuses me since i had dragged them over to my library to make sure that i had everything in my library and on my device. Not a big problem, since i just dragged them in itunes from my library to my device but sometimes i wonder if i understand the big picture:)

  • Can't figure out how to keep two different sites...

    How can I keep two sites and be able to get to both of them. When I create an iMovie and go to the share tab to share it wants to put it in the last site I created. What if that's not the site I want it on? I can't figure out how to go back and forth to the sites and update them without them writing over each other...

    Baldredlion:
    Regarding Varkgirls suggestion about iWebSites:
    I use iWebSites to manage multiple sites.. It lets me create multiple sites and multiple domain files.
    If you have multiple sites in one domain file here's the workflow I used to split them into individual site files with iWebSites. Be sure to make a backup copy of your Domain.sites files before starting the splitting process.
    This lets me edit several sites and only republish the one I want.
    Do you Twango?
    15 MBP 2.16Ghz; G5 Dual Core 2GHz, 2G RAM, 250G HD; G4 Dual 1Ghz, 1.5G RAM;   Mac OS X (10.4.9)   22" LCD, 710G FW HDs, Canon: SD700IS/i850/LIDE 50, Epson R200, 30G iPod, 2G Nano

  • Can't figure out how to send photos to outside lab

    Hello, I am new to Apple products and have had my iMac desktop for one week.   I am not very computer savy to start with and it is so different from my old pc.   I also have a new camera - Nikon D7100 - so I am attempting to learn TWO new things.  At least my camera came with a user's manual.  With my iMac I am stumbling through trial and error and taking up way too much time.   I tried using iPhoto but ended up losing my photo library I started (somehow it just disappeared after a series of error messages saying it was attempting to repair the library).  I ended up buying the Aperture app beause I want to be able to do more with photos for my art business. Now I am thinking iPhoto wasn't so bad, all except loosing my library, of course.  It was very simple to use.  But once I learn more I think I will appreciate  Aperture and at least through Aperture I was able to have my photo library restored.   I do not have a good printer yet, however, so I am attempting to have an outside print lab download my pictures to have the prints mailed to me.  (Note: I used to use Snapfish but didn't like my last batch of pics.  Someone suggested Walgreen's Photo Lab.   Maybe someone has a better suggestion.)
    However, I cannot download my pictures to any outside site because they said they must be in jpeg format.  My camera is set to take ONLY jpeg photos right now - I need to master this before even attempting raw - so the problem must be on the software use end.  When I transfer pics from my camera to my computer, Aperature (or is it thru iPhoto to Aperature I don't know) it gives them a name without a suffix attached.  I see that they identify the photo as JPEG at the top of the Info screen and I can go in and change the name and make it SAY .jpeg but even then I cannot download it to an outside photo lab for the same reason - "must be in jpeg format."    Plus to change the name to include the suffix .jpeg I am having to do that one picture at a time - there must be an easier way.  How do I make them all be .jpeg photos that can be recognized by outside photo labs?
    I would be open to sending my pics to the Apple photo print lab but I can only figure out how to send ONE at a time and that seems very impractical so I am obviously doing something wrong there.  How does the Apple photo lab compare to others?   How do I send a batch of photos at one time?  
    One other question not related to photos - With my p.c. I had a mouse that would let me right-click and move, copy or delete highlighted areas.  I cannot find that function at all with my iMac.  Is there a "right click" type of function on this computer?   I have this cool touch-pad.  No more mouse.   Sorry to be do dense.  I need users manuals I guess.  More hours.   I would appreciate any help so I can spend more time outside in my garden instead of hunched over my computer in frustration.   Thank you! 
    Oh, one more thing.  I cannot figure out my operating system.   My iMac box says "Preinstalled OS X and iLife4"    How can I find what version I have? That would be helpful.

    Try this to learn about using keys:
    http://www.apple.com/support/macbasics/
    You can also use your PC mouse.
    As for iPhoto, it sounds like you were trying to move files around in the library. That is a bib no-no in Aperture or iPhoto.

  • Metacity/compiz, can't figure out what to do.

    Sooo, I just installed arch linux again to play around, starting at a fresh install I installed an xserver and got it running right, then I started installing some WMs and installed lightdm and lightdm-gtk3-greeter.
    So far so good, when I do try to login all WMs show up except metacity/compiz, that's not really a problem so I decide to add the entries manually
    both are in /usr/share/xsessions
    [Desktop Entry]
    Version=1.0
    Encoding=UTF-8
    Name=metacity
    Name[en_US]=metacity
    Terminal=false
    Exec=metacity
    TryExec=metacity
    Name[en_US.UTF-8]=metacity
    Type=Application
    [Window Manager]
    SessionManaged=true
    and
    [Desktop Entry]
    Version=1.0
    Encoding=UTF-8
    Name=Compiz
    Name[en_US]=Compiz
    Terminal=false
    Exec=compiz ccp
    TryExec=compiz ccp
    Name[en_US.UTF-8]=compiz
    Type=Application
    [Window Manager]
    SessionManaged=true
    From what I can tell the entries are right, they don't throw any errors and I get to a desktop and I have a cursor (no menus of any type though)
    The issue is that I have no clue how to proceed, I configured compiz with ccsm but can't figure out how to add menus, my goal is to make it look like GNOME2 without all the bloat (all I should need is metacity and compiz, true?), another thing I want is a fancy floaty dock and conky, conky is installed and I'll configure it once my desktop looks decent, the dock I chose is cairo-dock because it looks nice (does it auto-hide? Auto hiding is absolutely critical.)
    Anyway, I did my research, I read the compiz-article on the wiki (I installed 0.9.x if it matters) but I do not know how to get the config running, the syntax for .xinitrc is rather different from a .desktop file, Google didn't help nor did the forums search function.
    Did I mention what I want it to look like? I don't think so... anyway, I want it to look like gnome2 with the applications menu and places menu (have a look at debian 6.x if you don't know what it looks like) but I am rather lost ^^;
    Sorry for being so uneducated, I hope I don't cause someone too much pain with my silly questions.
    Last edited by CubeGod (2014-02-07 06:40:16)

    Chazza wrote:The .xinitrc file is only useful if you are using startx. It is not going to make any difference to how you start sessions from lightdm. Quite frankly though, why not use .xinitrc and startx? It's by far the easiest way to autostart programs with a session. Compiz was not designed to be used as a standalone window manager and, as such, does not have an autostart utility of its own. Like I said earlier, you can put all the startup commands for the programs you want to autostart in your .xinitrc file and start the session with startx. No xsession files are required for that, of course. If you must use a Display Manager you may be able to parse startup commands through it using an xprofile file. There is a little information on that here: https://wiki.archlinux.org/index.php/Xprofile. As for your Metacity xsession file, I have no idea why you wrote that. There is no need for it. As has been pointed out earlier, Metacity is a window manager completely seperate from Compiz which is also a window manager. Metacity cannot be used alongside Compiz and is not required by Compiz itself in any way.
    Obviously, I thought you'd realize I knew that .xinitrc wasn't relevant since I added the "I thought it was only used when startx is called or am I mistaken?" but I digress; I'm not sure why you keep questioning my motives though, if I want to use lightdm then I don't want to use startx, whatever my reasons may be are rather irrelevant.
    Anyway, thanks for the link, at least it gives me something to work with (I'm sure I can figure out the syntax based on the xfce4 file)
    Oh and I know compiz wasn't designed to be used standalone but I am not going to be stopped by that, for the metacity xsession file I wrote that as a test. If I recall GNOME2 uses metacity as the window manager and compiz as the compositor (which I know is a working setup, however it was merely a test), so yes. They can be used alongside each other since compiz has a quite capable compositor.
    Chazza wrote:Ok. Fine. But you said you were after the educational experience so I was trying to suggest WM's that would be more suitable for a standalone session.
    Well yes, they may be a tad more user friendly but I have a similar philosophy with system building as playing games; Always play on the hardest difficulty.
    Chazza wrote:Why are you talking about gtk themes? They are not relevant. They are for desktop applications, they are not for window managers. When you are talking about a window manager theme you are talking about what the window border looks like and nothing else besides. What you need to understand about Compiz is that it is a window manager that does not come with its own decorator (the decorator being the progam that provides windows with borders.) As such, there are three decorators that can be used with Compiz: compiz-decorator-gtk, kde-window-decorator and emerald. The first is dependent on Metacity and uses Metacity themes. It is what is installed with the compiz-dev and compiz-bzr packages (I assume you installed Compiz with one of these packages as you said you were using the 0.9 version.) The second is dependent on Kwin and uses Kwin themes. The third is not dependent on any window manager and has its own themes. Why is there a setup like this? Because it was expected that you would use Compiz with either GNOME or KDE so it made sense to have decorators that could use the themes already available for the desktop environment's native window manager.
    Ah, a keen observation there! But if you would've paid attention I was also talking about compiz themes, you see the compiz theme I use also comes with a matching GTK theme, the GTK theme looks silly without the compiz theme and the compiz theme looks silly with other gtk themes. (that I have tried).
    Further I am aware that compiz uses three different decorators (based on choice), my theme has an emerald theme and a metacity theme included, I can pick either (isn't it nice?) and indeed I am using the compiz-dev package.
    Chazza wrote:Compiz is not a window decorator, it is a window manager, just like Metacity or Kwin or Xfwm or Mutter or Openbox etc etc. As I said above, the difference is that Metacity, Xfwm, Kwin etc all come with their own native window decorators. Compiz does not. Compiz has some decorators that can utilise the themes of aformentioned window managers.
    ah yes, I started rambling towards the end it seems, I didn't mean window decorator I meant compositor, sorry about that.

  • There is a pattern to my crashes, but I can't figure out what it is...

    At my studio, we are running 2 separate rigs with Logic 8.0.2 on 10.5.6 Mac Pros, and we have been plagued by crashing/hanging when opening up sequences. It is maddeningly inconsistent, however, and I can't figure out a pattern to the crashes (occasionally fine, other times awful).
    The one pattern I can decipher seems to be from the crash reports - often the very first (chronologically last before the crash took place) three lines look like this:
    00001000 /Applications/Logic Pro.app/Contents/MacOS/Logic Pro
    017c1000 /Applications/Logic Pro.app/Contents/MacOS/../Frameworks/XSKey.framework/Versions/A/XSKey
    017ed000 /Applications/Logic Pro.app/Contents/MacOS/../Frameworks/XAudioUnits.framework/Versions/A/XAudioUni ts
    Now do any kind souls have any idea what these XSKey & XAudioUnits files/processes are? I can access them directly by examining logic 8's package contents, and I am wondering if one or both of those may be corrupted and need to be somehow replaced. But I would rather get any of your thoughts before I go crawling around in areas I am unfamiliar with.
    So any ideas? Anyone?

    Hi
    This any use?
    http://support.apple.com/kb/TS2914
    CCT

  • I can't figure out what's wrong with this code

    First i want this program to allow me to enter a number with the EasyReader class and depending on the number entered it will show that specific line of this peom:
    One two buckle your shoe
    Three four shut the door
    Five six pick up sticks
    Seven eight lay them straight
    Nine ten this is the end.
    The error message i got was an illegal start of expression. I can't figure out why it is giving me this error because i have if (n = 1) || (n = 2) statements. My code is:
    public class PoemSeventeen
    public static void main(String[] args)
    EasyReader console = new EasyReader();
    System.out.println("Enter a number for the poem (0 to quit): ");
    int n = console.readInt();
    if (n = 1) || (n = 2)
    System.out.println("One, two, buckle your shoe");
    else if (n = 3) || (n = 4)
    System.out.println("Three, four, shut the door");
    else if (n = 5) || (n = 6)
    System.out.println("Five, six, pick up sticks");
    else if (n = 7) || (n = 8)
    System.out.println("Seven, eight, lay them straight");
    else if (n = 9) || (n = 10)
    System.out.println("Nine, ten, this is the end");
    else if (n = 0)
    System.out.println("You may exit now");
    else
    System.out.println("Put in a number between 0 and 10");
    I messed around with a few other thing because i had some weird errors before but now i have narrowed it down to just this 1 error.
    The EasyReader class code:
    // package com.skylit.io;
    import java.io.*;
    * @author Gary Litvin
    * @version 1.2, 5/30/02
    * Written as part of
    * <i>Java Methods: An Introduction to Object-Oriented Programming</i>
    * (Skylight Publishing 2001, ISBN 0-9654853-7-4)
    * and
    * <i>Java Methods AB: Data Structures</i>
    * (Skylight Publishing 2003, ISBN 0-9654853-1-5)
    * EasyReader provides simple methods for reading the console and
    * for opening and reading text files. All exceptions are handled
    * inside the class and are hidden from the user.
    * <xmp>
    * Example:
    * =======
    * EasyReader console = new EasyReader();
    * System.out.print("Enter input file name: ");
    * String fileName = console.readLine();
    * EasyReader inFile = new EasyReader(fileName);
    * if (inFile.bad())
    * System.err.println("Can't open " + fileName);
    * System.exit(1);
    * String firstLine = inFile.readLine();
    * if (!inFile.eof()) // or: if (firstLine != null)
    * System.out.println("The first line is : " + firstLine);
    * System.out.print("Enter the maximum number of integers to read: ");
    * int maxCount = console.readInt();
    * int k, count = 0;
    * while (count < maxCount && !inFile.eof())
    * k = inFile.readInt();
    * if (!inFile.eof())
    * // process or store this number
    * count++;
    * inFile.close(); // optional
    * System.out.println(count + " numbers read");
    * </xmp>
    public class EasyReader
    protected String myFileName;
    protected BufferedReader myInFile;
    protected int myErrorFlags = 0;
    protected static final int OPENERROR = 0x0001;
    protected static final int CLOSEERROR = 0x0002;
    protected static final int READERROR = 0x0004;
    protected static final int EOF = 0x0100;
    * Constructor. Prepares console (System.in) for reading
    public EasyReader()
    myFileName = null;
    myErrorFlags = 0;
    myInFile = new BufferedReader(
    new InputStreamReader(System.in), 128);
    * Constructor. opens a file for reading
    * @param fileName the name or pathname of the file
    public EasyReader(String fileName)
    myFileName = fileName;
    myErrorFlags = 0;
    try
    myInFile = new BufferedReader(new FileReader(fileName), 1024);
    catch (FileNotFoundException e)
    myErrorFlags |= OPENERROR;
    myFileName = null;
    * Closes the file
    public void close()
    if (myFileName == null)
    return;
    try
    myInFile.close();
    catch (IOException e)
    System.err.println("Error closing " + myFileName + "\n");
    myErrorFlags |= CLOSEERROR;
    * Checks the status of the file
    * @return true if en error occurred opening or reading the file,
    * false otherwise
    public boolean bad()
    return myErrorFlags != 0;
    * Checks the EOF status of the file
    * @return true if EOF was encountered in the previous read
    * operation, false otherwise
    public boolean eof()
    return (myErrorFlags & EOF) != 0;
    private boolean ready() throws IOException
    return myFileName == null || myInFile.ready();
    * Reads the next character from a file (any character including
    * a space or a newline character).
    * @return character read or <code>null</code> character
    * (Unicode 0) if trying to read beyond the EOF
    public char readChar()
    char ch = '\u0000';
    try
    if (ready())
    ch = (char)myInFile.read();
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    if (ch == '\u0000')
    myErrorFlags |= EOF;
    return ch;
    * Reads from the current position in the file up to and including
    * the next newline character. The newline character is thrown away
    * @return the read string (excluding the newline character) or
    * null if trying to read beyond the EOF
    public String readLine()
    String s = null;
    try
    s = myInFile.readLine();
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    if (s == null)
    myErrorFlags |= EOF;
    return s;
    * Skips whitespace and reads the next word (a string of consecutive
    * non-whitespace characters (up to but excluding the next space,
    * newline, etc.)
    * @return the read string or null if trying to read beyond the EOF
    public String readWord()
    StringBuffer buffer = new StringBuffer(128);
    char ch = ' ';
    int count = 0;
    String s = null;
    try
    while (ready() && Character.isWhitespace(ch))
    ch = (char)myInFile.read();
    while (ready() && !Character.isWhitespace(ch))
    count++;
    buffer.append(ch);
    myInFile.mark(1);
    ch = (char)myInFile.read();
    if (count > 0)
    myInFile.reset();
    s = buffer.toString();
    else
    myErrorFlags |= EOF;
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    return s;
    * Reads the next integer (without validating its format)
    * @return the integer read or 0 if trying to read beyond the EOF
    public int readInt()
    String s = readWord();
    if (s != null)
    return Integer.parseInt(s);
    else
    return 0;
    * Reads the next double (without validating its format)
    * @return the number read or 0 if trying to read beyond the EOF
    public double readDouble()
    String s = readWord();
    if (s != null)
    return Double.parseDouble(s);
    // in Java 1, use: return Double.valueOf(s).doubleValue();
    else
    return 0.0;
    Can anybody please tell me what's wrong with this code? Thanks

    String[] message = {
        "One, two, buckle your shoe",
        "One, two, buckle your shoe",
        "Three, four, shut the door",
        "Three, four, shut the door",
        "Five, six, pick up sticks",
        "Five, six, pick up sticks",
        "Seven, eight, lay them straight",
        "Seven, eight, lay them straight",
        "Nine, ten, this is the end",
        "Nine, ten, this is the end"
    if(n>0)
        System.out.println(message[n]);
    else
        System.exit(0);

  • How do I log into my iCloud account. I have iCloud installed on my iPad but can not figure out how to log into my iCloud account to restore a message

    How do I log into my iCloud account. I have iCloud installed on my iPad but can not figure out how to log into my iCloud account to restore a message

    Settings / iCloud on the iOS device to view your settings and options.
    Storage & Backup / iCloud Backup is how you restore the device with your last backup.

Maybe you are looking for