How to search every file on a computer in java

Hey guys, right now im writing a mac antivirus (i mostly use windows)
i have the test code to search for hex code clips i have another file to use so i can replace it using a updater to make getting new virus terms more easy. but what it the way to go through and read every file? i can set a file, but i need a way for it to run though the computer like a read antivirus
plz help guys, you guys are the best

ohh so u know im not lying, his was a first draught from a while ago
import java.io.*;
class AntiVirus
    public static void main (String args[])
          //bin = new Signature(file);
          File f = new File("junk.dll");
          //File f = new File("Test20041025.java");
          if ((int)f.length() > Integer.MAX_VALUE) {
               System.out.println("Not enough memory to read file.");
               System.exit(-1);
          byte[] bytes = new byte[(int)f.length()]; // assume < 2gb
          RandomAccessFile raf = null;
          try
                raf = new RandomAccessFile(f,"r");
                raf.readFully(bytes);
                raf.close();
          catch (Exception e)
               System.out.println(e.toString());
               System.exit(-1);
          //String result = new String(bytes /*, encoding*/ );
          //byte[] testPatternB = new byte[testPatternS.length];
          int[] testPatternS = { 0x07, 0x08, 0x09, 0xAB, 0xBF, 0x62, 0x04 };          
          byte[] testPatternB = new byte[testPatternS.length];
          int[] testPatternS2 = { 0x07, 0x08, 0x09, 0xAB, 0xBF, 0x62, 0x04 };          
          byte[] testPatternB2 = new byte[testPatternS.length];
          for (int i = 0; i < testPatternS.length; i++)
               testPatternB[i] = (byte)testPatternS;
          for (int i = 0; i < testPatternS2.length; i++)
               testPatternB2[i] = (byte)testPatternS2[i];
          String pattern = new String(testPatternB);
          String fileBytes = new String(bytes);
          String pattern2 = new String(testPatternB2);
          //System.out.println(fileBytes.indexOf(pattern));
          if(fileBytes.indexOf(pattern) > 0 && fileBytes.indexOf(pattern2) > 0 ) // if a file is found it its a random number 1-??? so i do a check to tell
          System.out.println("You Have a Serios Virus");

Similar Messages

  • A Friend Was Working On My Mac Pro And Now Every File On The Computer Shows

    A friend was using the Mac Pro to look at a disc, and he said he went into Terminal. Now, every file on the computer shows. He hasn't gotten back to me, and it's a little annoying, seeing ALL the faded envelopes with minus signs, and extra files. I hope this makes sense. I know he went into Terminal, and it had something to do with Finder and show all, or something. Any help is appreciated.

    Open the Script Editor in the /Applications/AppleScript/ folder and run the following:
    do shell script "defaults write com.apple.finder AppleShowAllFiles 0"
    Click on the Finder in the Dock with the Control and Option keys held down and choose Relaunch. Some third-party utility software will also do this.
    (52543)

  • How do I transfer files from one computer to another without using cables??

    How do I transfer files from one computer to another without using cables?

    Wifi network
    Email
    Thumb Drive
    Online storage such as, iCloud Google Docs, SkyDrive, etc.

  • How can I transfer files from my computer to my I pad ?

    How can I transfer files from my computer to my I Pad?

    Try a conduit such as Dropbox.
    Goodreader or Documents to Go also have helper apps that allow transfers.
    Goodreader is particularly good in that it has a integal file tree and you can mount your computers harddrive and navigate directly on your ipad.
    Use the open with to view/move files into other apps.

  • How to search to files based on the metadata of the category in CS

    Hi,
    Can any one tell me how to search the files in the content services based on the metadata of the Category,I know how to search based on the Category using
    public static void attributSearch(String searchString)
    throws FdkException, RemoteException, Exception
    // get the Manager instances
    SearchManager sem = s_WsCon.getSearchManager();
    CategoryManager cat = s_WsCon.getCategoryManager();
    CommonManager cm = s_WsCon.getCommonManager();
    FileManager fm = s_WsCon.getFileManager();
    Item folder = fm.resolvePath("/idc/workspaces/BoardMembersProject", null);
    AttributeRequest[] catAttr =
    WsUtility.newAttributeRequestArray("ProjectCategory");
    // create AttributeRequest to retrieve CATEGORIES attribute
    AttributeRequest[] catClassAttr = WsUtility.newAttributeRequestArray(
    Attributes.CATEGORIES, catAttr);
    // define search options
    NamedValue[] nv = WsUtility.newNamedValueArray(new Object[][] {            
    { Options.SEARCH_VERSION_HISTORY, Boolean.TRUE },
    { Options.RETURN_COUNT, new Integer(100)
    // get search expresiion
    SearchExpression seExp = new SearchExpression();
    // searchString ="ProjectCategory";
    Item[] item = cat.getRequiredCategories(folder.getId(),catClassAttr);
    seExp = new SearchExpression();
    NamedValue[] attributes = item[0].getRequestedAttributes();
    seExp.setOperator(FdkConstants.OPERATOR_HAS_CATEGORY);
    seExp.setRightOperand("["+item[0].getName()+"]");
    // search documents
    NamedValue[] result = sem.search(seExp, nv, null);
    // search result display
    for (int i = 0; i < result.length; i++)
    if (result.getName().equals(Options.SEARCH_RESULTS))
    Item[] resulItem = (Item[]) result[i].getValue();
    WsUtility.log("Kveni",resulItem);
    if (resulItem != null)
    for (int j = 0; j < resulItem.length; j++)
    WsUtility.log("File " +resulItem[j].getName());
    But how do one search Based on the attributes of the category??
    thanks
    kveni

    Download the PM accelerator kit appropriate to your environment, and check out the TestSearch2.java example.
    http://www.oracle.com/technology/products/cs/developer/contentservicesdev/contenservicesdevkit.html
    Essentially you need to lookup the internal names of your category attributes, as well as have the internal name of your category class.
    categoryClassName = ...; // e.g. AHC_XXX
    attribute1name = ....; // e.g. CUSTOM_MYBOOLATTR
    you then create a normal search expression such as
    String attribute1Operand = "[" + categoryClassName + FdkConstants.SEPARATOR + attribute1name + "]";
    SearchExpression expr1 = new SearchExpression();
    expr1.setOperator(FdkConstants.OPERATOR_EQUAL);
    expr1.setLeftOperand(attribute1Operand);
    expr1.setRightOperand(Boolean.TRUE);
    Matt.

  • How to add .m4r files from my computer to my tones in iPhone 6 iOS 8.1.1 ?

    How to add .m4r files from my computer to my tones in iPhone 6 iOS 8.1.1 ?

    You've sycned other content via your computer's iTunes to the phone ?
    You can sync photos to your phone via your computer's iTunes : connect your phone to your computer, click on its icon towards the top left of the iTunes screen, and select Photos on the left-hand side of the screen :
    Photos that you sync from a computer can't be deleted directly in the phone's Photos app, instead they are deleted by not including them in the next photo sync - so you will need to include all photos that you want from your computer in each photo sync.

  • How do i select files on my computer to back up to the cloud?

    how do i select files on my computer to back up to the cloud?

    Hi Tholley,
    You could either upload them using a browser at https://creative.adobe.com/files or using the file sync feature in Creative Cloud.
    This document goes over the process:
    http://helpx.adobe.com/creative-cloud/help/sync-files.html
    - Dave

  • How To read/write file on remote server in java

    Hi All,
    How To read/write file on remote server in java? I mean using URL - http://www.xyz.com can I right file to that perticular server.
    Thanks in advance

    If your server support a means of uploading files you can.
    A popular means is [http://en.wikipedia.org/wiki/WebDAV]
    However, by default web server don't allow you upload files, its usually something you need to configure or install.
    I suggest you have a look at your web servers documentation.

  • How do i move files from one computer to a new computer for ipod touch

    My computer that has all the ipod files etc on it has crashed.  I need to know how to move them to a new computer.

    Recovering your iTunes library from your iPod or iOS device: Apple Support Communities

  • How to view cc files on a computer that only has photoshop cs6

    I have the new version of photoshop on my computer that only allows me to save files as: photoshop cc.  However, I would like to transfer these files to view on a computer, which is at school, that only allows me to view files from photoshop cs6 or older (cs4, etc.).  I would like to work on projects on my personal computer at home and finish them on the computer at school.  So, how can see my files that are in creative cloud on a computer that only has photoshop cs6?

    Need a little more information.  Never heard of a Photoshop cc file, maybe I'm missing something.  When you save a file the first time there is a drop down menu allowing you to save the photo as a number of different file extensions, i.e.. PSD, tiff, jpeg.  There is no photoshop cc.  File uploaded to your folder on the cloud retain their extensions.

  • How to search a file from a hierarchy and delete it

    hi ,
    i have to delete a file from a directory structure .i dno't know where is file stored in my folder hierarchy .i have to search that file and delete that file .
    for example ;
    i have a folder name A , which have folder B ,C ,D ,E . B folder have other 2 folder or 3 file (anything) , same C and D And E can have file or folder .
    means we dnot know that A folder have how many files or folder in it . in that we have to search a specific file and delete it .

    hi vineet ,
    this is only for u .
    here is my code
    class serDir
         public static void main(String[] args)
              String dirname="/java";
              File f1=new File(dirname);
              if(f1.isDirectory()){
                   System.out.println("directory name "+dirname);
                   String s[]=f1.list();
              for(int i=0;i<s.lenght();i++){
              File f=new(dirname +"/"+ s);
              if(f.isDirectory()){
    System.out.println("directory name "+s[i]);
                   } else {
                   System.out.println("file name "+s[i]);
              } else {
              System.out.println(dirname+"is not directory" );
    but not working properly , now plz tell me what changes i should make to full fill my requirement . question is still same ....................waiting

  • How to search for file in jsp page

    i need help on how to search for a file in a folder where there is a lot of subfolder.like how u search in a document in windows. i need a complete codes in jsp page.
    thank you in advance.
    Message was edited by:
    n_dilah

    no i need to do a search engine in jsp page which is the j2ee.
    i type smth than tat file from any folder will appear the same way when u need to search your file in a document in windows.
    well can u nice people tell me where i can get the codes bcos i stinks when it come to programming.
    thank you very very very much.

  • How do I save files to my computer?

    How do I save a file I created and uploaded to my computer?

    Hi p stephon,
    Are you referring to files that are saved in your Acrobat.com online account? If you'd like to save those files to your computer, please follow these steps:
    Log in to your account at https://cloud.acrobat.com/files.
    Select the file or files that you want to download and click the Download link at the top of the files list. Your files will be downloaded to the Downloads folder on your desktop.
    Please let us know how it goes.
    Best,
    Sara

  • How to search for files using wildcards * and ?.

    Hi All,
    I've been searching the forum for a couple of hours now and have been unable to find a good example of how to search a directory (Windows OS) for a file using wildcards * and/or ?. Does anyone out there have a good example that they can share with me?
    Thanks

    Hi All,
    First of all I want to thank everyone for taking the time to respond to my question. All of your responses where greatly appreciated.
    I took the example code that was posted by rkconner, thanks rkconner, and modified it to allow me to search for files in a directory that contain * and/or ?. Yes, I said and/or! Meaning that you can use them both in the same file name, example: r??d*.t* would find readme.txt.
    I've posed my complete and thoroughly document code below. I hope it is very helpful to other as I have searched many forums and spent many hours today trying to resolve this problem.
    Enjoy
    * File Name: WildcardSearch.java
    * Date: Jan 9, 2004
    * This class will search all files in a directory using the
    * asterisk (*) and/or question mark (?) as wildcards which may be
    * used together in the same file name.  A File [] is returned containing
    * an array of all files found that match the wildcard specifications.
    * Command line example:
    * c:\>java WildcardSearch c:\windows s??t*.ini
    * New sWild: s.{1}.{1}t.*.ini
    * system.ini
    * Command line break down: Java Program = java WildcardSearch
    *                          Search Directory (arg[0]) = C:\Windows
    *                          Files To Search (arg[1]) = s??t*.ini
    * Note:  Some commands will not work from the command line for arg[1]
    *        such as *.*, however, this will work if you if it is passed
    *        within Java (hard coded)
    * @author kmportner
    import java.io.File;
    import java.io.FilenameFilter;
    public class WildcardSearch
         private static String sWild = "";
          * @param args - arg[0] = directory to search, arg[1] = wildcard name
         public static void main(String[] args)
              String sExtDir = args[0]; // directory to search
              sWild = args[1];   // wild card to use - example: s??t*.ini
              sWild = replaceWildcards(sWild);
              System.out.println("New sWild: " + sWild);
              File fileDir = new File(sExtDir);
              File[] arrFile = fileDir.listFiles(new FilenameFilter()
                   public boolean accept(File dir, String name)
                        return (name.toLowerCase().matches(sWild));
              for (int i = 0; i < arrFile.length; ++i)
                   System.out.println(arrFile.getName());
         }     // end main
         * Checks for * and ? in the wildcard variable and replaces them correct
         * pattern characters.
         * @param wild - Wildcard name containing * and ?
         * @return - String containing modified wildcard name
         private static String replaceWildcards(String wild)
              StringBuffer buffer = new StringBuffer();
              char [] chars = wild.toCharArray();
              for (int i = 0; i < chars.length; ++i)
                   if (chars[i] == '*')
                        buffer.append(".*");
                   else if (chars[i] == '?')
                        buffer.append(".{1}");
                   else
                        buffer.append(chars[i]);
              return buffer.toString();
         }     // end replaceWildcards method
    }     // end class

  • How to search xml file data based on the given keyword from html form

    hi,
    i'm new to XML. I have this problem regarding searching within a XML file.
    the
    idea is that my search will be based on the keyword entered
    in
    by the user from a HTML form. the keyword is then used to search all
    the
    question nodes and the choice nodes within a XML file. once the match
    is
    found, i will have to display the results.
    But i don't know how to do so - especially the part of searching xml file.
    Can
    anyone help me in this? Your help is much appreciated.
    Edited by: Moti_Lal.D on Apr 4, 2008 7:28 AM

    yeah.. what i was trying to do is
    i have one xml fine. then i have to read all the tag values say
    <book>
    <title>Java</title>
    <author>agarwal</author>
    <price>200</price>
    </book>
    <book>
    <title>Xml</title>
    <author>saxmann</author>
    <price>300</price>
    </book>
    i can read the tag values like this
    File file = new File("dom.xml");
    try {
    DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    Document doc = builder.parse(file);
    NodeList nodes = doc.getElementsByTagName"book");
    for (int i = 0; i < nodes.getLength(); i++) {
    Element element = (Element) nodes.item(i);
    NodeList title = element.getElementsByTagName("title");
    Element line = (Element) title.item(0);
    what i want is i may give any xml file
    like File file = new File("xxx.xml");
    (it may be one level/two level/3level tagged one)
    then the i should read all the tag values and store them in some array. Then when i enter some character from keyboard (say "a") then it has to show all the tag values starts with "a" and display them.
    i guess u understand my problem.

Maybe you are looking for