Simple find and raplace

Who can please show me the best way to write Say (in /java)
Read a file when java JavaFindReplace.class fileName
is typed in commant line
In JavaFindReplace.class
will be
open file specified
read the file
find everywhere there is "abcd"
and replace with "1234"
End
What is the best way to do this
Thank you

Here's a slightly more complicated search and replace that will replace strings across multiple files of a specified type.
Should serve as a basis for what you want...
package mypackage;
import java.util.*;
import java.io.*;
public class FindReplaceApp
private static void _createFileList(ArrayList list)
File root = new File(ROOT);
File[] files = root.listFiles(new FileFilter());
for (int i=0; i<files.length; i++)
list.add(files);
public static void main(String[] args)
try
java.util.ArrayList files = new ArrayList();
_createFileList(files);
for (int i=0; i<files.size(); i++)
File aFile = (File)files.get(i);
BufferedReader reader = new BufferedReader(new FileReader(aFile));
BufferedWriter writer = new BufferedWriter(new FileWriter(OUTPUT + "\\" + aFile.getName()));
String line = reader.readLine();
while (line != null)
line = line.replaceAll(FIND, REPLACE);
writer.write(line);
writer.newLine();
line = reader.readLine();
reader.close();
writer.flush();
writer.close();
catch (Throwable t)
t.printStackTrace();
private static class FileFilter implements FilenameFilter
public boolean accept(File file, String name)
if ((name.toLowerCase().endsWith(_htmExt)) ||
(name.toLowerCase().endsWith(_htmlExt)))
return true;
return false;
private String _htmExt = ".htm";
private String _htmlExt = ".html";
public static final String ROOT = "C:\\Documents and Settings\\Neil\\My Documents\\webpages\\AdamJoel\\pages";
public static final String OUTPUT = "C:\\Documents and Settings\\Neil\\My Documents\\webpages\\AdamJoel\\newpages";
public static final String FIND = "slide changes every 10 seconds";
public static final String REPLACE = "slide changes every few seconds";

Similar Messages

  • Simple Finder and Services Preferences

    When I put on simple finder, how do I shut off the services preferences?  It shows up under the finder?  I don't want my students changing our settings!Thank you.

    Hey CentralMiddleSchool,
    According to the following document, if you’re an administrator for the user’s computer, you can make changes. So, as long as your students don't have the Administrator password, you should be ok:
    OS X Mountain Lion: Change preferences for a user’s simple Finder
    http://support.apple.com/kb/PH10747
    There's more information about it here:
    OS X Mountain Lion: Set up a simple desktop and Finder
    http://support.apple.com/kb/PH10760
    Welcome to Apple Support Communities!
    All the best,
    Delgadoh

  • Simple finder and Unix

    How would you create a simple finder user with unix in leopard?

    I not sure but I think it has to do with mcx settings. This is what I get from the shell-
    % apropos mcx
    mcxalr(1) - Managed Client application launch restriction tool and agent
    mcxquery(1) - Managed Client (MCX) compositor query tool
    biovizier is a mcx guru. Maybe he'll run across this post.

  • VERY simple find and execute script to be improved

    hello, I've been searching for other scripts like the following but have found nothing, so decided to hack this together. I have almost 0 bash programming experience, so I'm sure some kind soul could easily improve it. The functionality should be obvious to anyone here. It could probably do with some limit to the files being searched for, but I only use it in directories and with queries that I know won't give lots of results. Obviously, if there's some better script/option that my google fu couldn't find, then please let me know. Smart arse one liners more than welcome.
    #!/bin/bash
    finder=`find ./ -iname "*$1*" -printf %p\:`
    IFS=:
    select filename in $finder
    do
    echo "enter command to run on $filename"
    read commandtodo
    $commandtodo $filename
    break
    done
    unset IFS

    Just after I went to bed lastnight I figured out the simplest way (i.e. only way I understand) to do what I wanted - just put it as a function in your .bashrc file.  Export doesn't work from a script back to the shell it was called from - that's what I was trying to say last night. So then, the final function is this:
    fns() {
    export IFS=:
    select X in `find ./ -iname "*$1*" -printf %p\: `
    do
    echo "enter command to run on $X"
    read commandtodo
    $commandtodo $X
    break
    done
    unset IFS
    This works great. If any newbies stumble upon this page (I've been looking for something like this since I started using the command line) then I'll briefly run through how it works:
    1 - you type "fns x" where x is a word or partial word you know is in the filename
    2 - you select whichever of the found files/directories you want
    3a - you can then enter a command to run (e.g. vim)
    3b - or just hit ctrl-c to return to the prompt, and then use $X in place of wherever you would have put the path in the command you want to run. e.g. "cd $X" will move you to that directory, if it was a directory you were looking for
    Hope this helps someone
    As for the other options from Procyon/karol - thanks, but again, over my head. I don't think I have xdotool installed. Script didn't work anyway, but mine is fine for now.
    Thanks

  • Allowed Apps don't show in Simple Finder

    Ok, because of the nature of this problem I didn't know exactly where to post this, so hopefully this is a good place...
    I work at a High School where we've got about 30 or so student laptops available for teachers to check out to use in their classes. They are all iBook, iBook G4, PowerBook G4, and MacBook computers, and all running OSX 10.4.11. The problem I'm having is with Microsoft Office X and Simple Finder. I have it installed on all of the computers, but for some reason the MacBooks won't show it in Simple Finder. It works just fine on all of the other computers, but the 6 that are MacBooks won't work. I set them up the same as all the others and nothing... I came up with the idea to try logging into a student account, running full finder and create aliases for Word, Powerpoint and Excel. I then returned to simple finder and they were all there and worked, but as soon as I logged out of the student account or restarted the computer the aliases were gone...
    Hopefully that makes sense. It's really frustrating because other than this one problem the computers are all setup the exact same, so I don't know why the MacBooks can't just do it like the others do. Any help would be greatly appreciated.
    (And if you know how to resolve this, in searching the forums I found a very similar (almost identical problem) post that is still unresolved in the leopard forums: http://discussions.apple.com/thread.jspa?messageID=8358649&#8358649)
    Thanks

    I found a number of similar threads - it's apparently a bug.
    I came up with the idea to try logging into a student account, running full finder and create aliases for Word, Powerpoint and Excel. I then returned to simple finder and they were all there and worked, but as soon as I logged out of the student account or restarted the computer the aliases were gone.
    It sounds as if you are putting the aliases into
    username/Library/Managed Items/My Applications/
    That seems to be the right idea, with further workarounds designed to stop them from being deleted when you log out. One way, according to [this thread|http://discussions.apple.com/thread.jspa?messageID=3183420&#3183420] is to lock the My Applications folder after putting in the aliases.
    Another workaround described in [this thread|http://discussions.apple.com/thread.jspa?messageID=5600449&#5600449] is to place the Office aliases somewhere else accessible, either in a subfolder of My Applications, or in the Documents or Shared folders.

  • Simple Finder issue displaying icons

    Hi,
    I've installed the Opera browser with the admin account, then created a normal user.
    I then enable Parental Control on that normal account, select simple finder and only allow Opera from loading (and go into the list and make sure it's selected).
    When I load with the user, Opera is not in the "My applications" folder, what's wrong?
    If I disable use simple finder the icon shows up and runs fine.
    Help please!

    Sometimes people want to use "Parental Controls" to limit what a user can do, but with a three year old, you probably don't have to worry too much about that. In that sort situation, try removing "Parental Controls" from the account (or you can use "Some Limits" if you wish).
    Then log into the account and arrange the "Dock" the way you want. Next, open "/Applications" > "Utilities" > "Terminal.app" and enter the commands below, which turn on the Finder's simplified interface (big icons; one-click access), and lock the "Dock" to prevent items from being removed:<pre>
    defaults write com.apple.finder InterfaceLevel simple
    defaults write com.apple.dock contents-immutable -bool true</pre>
    Then log out and back in. This doesn't fully reproduce the "Simple Finder" interface, but it covers a couple of the most obvious aspects. If necessary, futher settings can be introduced, à la carte as it were...

  • Simple Finder/Parental Controls Problem

    I recently did an erase and install on my eMac and am now having problems with Simple Finder and Parental Controls.
    I have an account set up for my daughter and I want to have Simple Finder running with about a half dozen or so applications for her to use. Prior to the erase-and-install, I had this set up and running fine. But now, even though I select all the programs I want under the Parental Controls preferences, only three show up (Safari, Dictionary, and TextEdit).
    I tried deleting and re-creating the account, repairing permissions, turning around twice and clicking my heels together, etc. with no success.
    Any ideas? Thanks!

    I ran disk utility and repaired the permissions--is that similar to what you suggest?
    When I did a erase-and-install of Leopard, I assume that it ran through a disk inspection and repair routine. But perhaps something more is needed.

  • Connecting to a local server using simple finder

    I am switching all my iMacs to OSX v10.2. I was told that it would run better for me than OS 9.2.
    When setting up user capabilities for my students, I am having some troubles. One, if I set it up where my students can view only applications that I want, they do not always appear under the student login.
    If I set it up where my students can only use simple finder and view an applications folder, then they lose the capability to see the local network servers.
    Is there anyway to set it up for users to still use a local network server when only using Simple Finder capabilities?
    If anyone could please help, it would be greatly appreciate.
    Thanks,
    Steve

    Check
    1.connect to db using remote desktop
    2.check v$session for info
    3.Terminate the desktop connection
    4. check the v$session view

  • Find and Replace across multiple topics

    I haven't used RoboHTML in a few years and am getting back to using it again. this is a fairly simple question, but the Help for RoboHelp doesn't seem to provide an answer.
      How do you do a simple find and replace across multiple topics?  I want to search for a text string and replace it with another text string.

    Hi,
    Have you tried to use the "Multiple File Find and Replace" option present in RoboHelp. You may access this option from Edit->Find and Replace in Files.
    Before trying to find the files, please ensure that the where field in the dialog points to the correct location of your project.
    Thanks

  • Simple Finder - Icon's Missing but Application Works

    I've got a number of applications on my kids two accounts that under the simple finder they show up as the blank page with the alias icon. I've tried repairing permissions, selecting/unselecting the setup and I've been unable to figure out how to get them back.
    The accounts are set up as simple finder, and to limit the applications. I have checked the apps in question and even checked/unchecked them trying to 'reset' them.
    Any suggestions?

    Was it candybar that deleted your finder icon?
    if so you just drag the custom icon (which is blank for the size you are using it in probably, reference picture) will POOF and your system icon should be restored. THEN you killAll Dock, which candybar does for you.
    which version of CandyBar do you have? the latest is the only one that will work effectivly on Lion.
    in icon composer, and when you preview an icon, you'll see that it is really a container with multiple images. A reason why your icons are coming up blank might be that the spaces for the the other icon sizes are empty. if you go into Icon Composer, you can drag in the other sizes and save as an ico. Then you'll have a working icon.

  • How to find and remove specific email messages

    I just read an article about a health department employee inadvertently sending a confidential e-mail to 800 users. The IT department shutdown the mail server and wihin an hour removed all copies of the message from the system.
    I asked myself, if that happened here, how would I do that? I could shutdown the Messaging Server, but not sure what to do after that.
    How would you identify, find, and remove a particular e-mail message from everyone's inbox?
    $ imsimta version
    iPlanet Messaging Server 5.2 HotFix 1.26 (built Mar 31 2004)

    Well, each message is stored as a simple text file in the store. Assuming unix, you could do a pretty simple find and grep, looking for a key phrase. exec rm from that, and you're done....
    After such brute force methods, you do need to run
    reconstruct -r

  • Parental Control accounts with Simple Finder won't log out

    Since upgrading to Snow Leopard, my children cannot logout. The accounts use Simple Finder and have Parental Controls set. To log out, we must Force Quit Finder. How do I fix this? Also, empty Trash does not empty the trash.

    enable full finder. go to home/library/preferences and delete the files com.apple.dock.plist and com.apple.finder.plist. then control-option click on finder in the dock and choose 'relaunch'. then start Activity Monitor ((it's in /Applications/Utilities) and force-quit Dock. switch back to simple finder and see if it works better now.

  • Blank application icon with Simple Finder

    I have parental controls turned on for my kids so that they can only see the simple finder. However, one of the application I've approved for them to use, Photo Booth, shows up in their simple finder as a blank icon that I cannot click on. The others work fine. I've tried switching between simple finder and not, but no luck. This has happened before with many icons turning blank, and I had to resort to deleting their account and recreating it. I don't want to go through that exercise again. Any suggestions?

    An "encrypted disk image" is something that can be created using tools included with OS X and might be satisfactory for encrypting arbitrary files. The procedure is described here:
    http://docs.info.apple.com/article.html?artnum=107333
    Keep in mind that the priority with encryption is keeping your data "secure", but not necessarily maintaining the integrity of the data - since the entire contents of the disk image are effectively wrapped up into a single encrypted file, even minor corruption of that file could potentially result in the loss of all of the data so maintaining up to date backups is essential.
    There are a few other things to be aware of, for example: When the disk image is mounted, it behaves just like a regular, non-encrypted volume so other users with access to the computer would be able to access its contents. The contents are only secure while the image is not mounted. For this reason, it might make sense to split up files into groups - things for which security isn't as important, or which need to be accessed frequently might benefit from being stored in a .dmg separate from the one containing the most sensitive, infrequently accessed files.
    Don't share the contents of the encrypted disk image over the network. Obviously this doesn't make any sense from a security perspective, but aside from that, if a local user and a remote user both make changes to any part of the dmg while it is mounted, there is pretty much guaranteed to be corruption, and a greatly increased risk of data loss.
    And unlike "Filevault", a stand alone disk image doesn't come with a "master password" backdoor so if the password is lost, its contents "will be irretrievably lost"...

  • Find and Replace simple action crashes Illustrator CC

    I am now trying Creative Cloud and I came with this bug. When I use a simple action to find and replace a text string in my file it will crash the Illustrator.
    My actions is pretty simple:
    Find > "aa" (I do have to check all the options to work)
    Find and Replace > "aa" to "2014.01.29"
    This action works well if I use it once by the Edit menu, but if I close the Illustrator and reopen, it'll not work again and will crash the software.
    Everyday I do update my action to actual date, so the action will work normally but sometimes I do have to close the app and I have to make the action again and again everytime.
    This was a problem already in CS5, last version that I used.
    I'm using Windows 8.

    Msot likely this isthe problem of the action playing back to fast.
    Actions Flyout >> playback options > set to altast 1 second
    You will need to change this setting each time you resart illustrator

  • How do I find and replace text in PHP files?

    How can I in CS3 make sitewide changes to the text in PHP pages without changing variable names etc that have the same name?
    For example if I have an installation of a PHP forum and I want to change every instance of the word 'forum' to 'message board'...
    If I used the 'inside tag' search with " as the tag, then if "" contained a variable called 'forum' it would also be changed and therefore corrupt the code....
    Is there a simple way around this?
    Thanks!
    I'm using CS3 on Windows Vista.

    It looks like you're trying to find and replace source code, so you may be able to look at the various places that are looked at when finding and uncheck the ones that don't apply.
    But, if it's all source code then that won't help.  One thing that may work is to expand the search option - for example if the work "forum" that you're wanting to change it preceded by another word, or character or something that sets it apart, then do you find on that. You can expand that search phrase as far out in either direction that you need to to make it different, if of course that is practical in your situation.
    The only other way I can think of is to somehow create an exception rule, but I'm not sure if that's possible or how to do it.

Maybe you are looking for

  • Change of UOM in material master?

    Dear SAPIENTS, I created a material  with UOM (M)just now and than assigned to inspection plan. Now I am changing the UOM of material to Nos.. I was getting following Error: The base unit of measure cannot be changed The reasons for this are Routings

  • Problem with importing a movie made in Keynote

    Hello I need to import a movie of a slideshow that I made with keynote into iMovie, but when I do so the slideshow movie from keynote is clipped/cropped by the screen in iMovie. How do I fix this?

  • HERE Maps for use in other countries

    Hi With merely HERE and I quote "...you can still download maps for the whole world to use, you can still have walk navigation everywhere in HERE Maps etc" Does that means you can activate Lumia 720's inbuilt compass and get voice guided walking navi

  • Why can see the jsp code in browser?

    Q1: I just setup completely the oracle application server downloading from OTN website. I have created a new OC4J instance 'appweb' in enterprise manager wizard form. I can look at the jsp code on the browse when I request the demo application instan

  • My MB Air makes a single beep-sound!

    My MB Air (mid 2012) keeps making a single beep-sound every 2 or 3 minutes, even when I shuted it down. I don't know why. Can anyone help?