Searching for a text file

hi i want to search for a file in the same folder as my project and read the contents of that file ... i know how to read from text file but i just need to know how i can search in the folder to look for a txt file called me.txt and open it for reading.. any suggestions?
thanks in advance
please provide some code for me... thx alot

Look at the File class in Java API. You can create a file object by passing the file name.
Then you can check whether the file exists or not by using exist methos of the File. (Of course, you need to know the path of the file).

Similar Messages

  • Searching for a text in the file.

    I have a to search for a particular text, in the file.
    Since my file is of large size, I do not want to read the file line by line searching for the text.
    Is there any API which will help me do this?

    arc_g wrote:
    Having found the text in the file, I want to read from that point/index to the end of the file.That I can do using RandomAcessFile.
    The point is to find the text in the fileIf your problem is related to http://forums.sun.com/thread.jspa?threadID=5378628&tstart=0 then you do not want to search from the front of the file.

  • Searching for a good file manager

    I'm searching for a good file manager. Konqueror 3.5 is quite good, dolphin 4.1 and konqueror 4.1 are not. Since konqueror 3.5 is going to die due to lack of support in the future, I kind of need to find a new good file manager...
    Do there exist file managers with the following features?
    Many of these features are things I thought were quite logical to be in a file manager, but seem to be missing in most "modern" ones...
    -independent of any desktop (gnome or KDE), just a standalone program
    -preferably not being both a web browser and file manager in once, at least not in an annoying way. Konqueror 3.5 shows that being that combination is possible without being annoying.
    -ability to have a tree view of the folders on one side and list view showing the files and subfolders of the folder currently selected in the tree on the other side
    -detailed list view showing at least filename, type, date and size, and the ability to sort according to any of these properties
    -a non-detailed view showing image contents would also be nice, to browse folders of photos or other images
    -ability to open files in certain programs if you doubleclick the file, NOT open it by singleclicking, singleclicking may only select it
    -ability to select multiple files by dragging box around files or using keys like "ctrl" and "shift"
    -ability to do "open terminal here" or type terminal commands in the current open directory
    -must have ability to drag files from one folder to another, from list view to tree view and vica versa, to move or copy them
    -and must have ability to use "ctrl+c" and "ctrl+v" to copy files and foldes from here to there
    -multiple tabs is a huge plus
    -favorites (to local folder paths) is also a huge plus
    -preview of files when hovering the mouse over them is nice
    -must have ability to zip and unzip (or other compression formats) folders by just right clicking them and choosing a zip/unzip command there
    -in addition to that, must also have ability to browse through a zip file as you would through a normal directory, and drag files from the insides of the zip file to the tree view to automatically unzip those files there, and of course "ctrl+c"/"ctrl+v" should also work to copy a file from the inside of the zip file, to some other folder on your disk
    -no horizontal autoscrolling in the tree view, that is an invention straight from the abyss...

    I know exactly how you feel about KDE 4 vs. 3 -- Konqueror was the best part of KDE for me (pretty much the only part I ever used, actually; my window manager is a slightly modified version of WMII and I generally loathe "desktop environments"). KDE 4 ruined it, completely and utterly.
    I submitted about 20 different bug reports about Konqeuror 4, mostly features that they'd deleted or mangled; some of them are starting to be addressed now. I don't think they'll ever fix the speed issues though, because those are dependent on the underlying KDE 4 libraries as far as I can tell -- it's as if KDE 4 were purposely and deliberately designed to be slower than KDE 3. Even if they fix all of its deficiencies, that'll probably keep me from using it...
    Right now there's KDEmod, which will hopefully maintain its KDE 3 branch for a while longer. It's starting to show some problems, though; I haven't been able to get kdemod konqueror 3 to work fully out of the box (the settings pages are all blank). On my main machine, I somehow managed to hack together some of the KDEmod3 packages so that I have a functional konqueror 3 running alongside the Arch repository's version of KDE4. I'm afraid to pacman -Syu now, though, because it will probably break horribly :P
    I don't remember exactly how I got konqueror 3 going like that, as I did it in my initial fit of rage after I did the pacman -Syu that got me KDE4 (a decision I have regretted ever since), but it was something like this:
    1. move /opt to /opt.kde4
    2. make a new /opt
    3. download several KDE 3 packages from the KDEmod3 repositories manually
    4. extract those packages into the new /opt with tar -xzf (NOT pacman!)
    5. try /opt/kde/bin/konqueror
    6. read reams of error messages about missing libraries, segfaults, etc.
    7. try to supply the missing libraries by downloading other kdemod3 packages and manually extracting them
    8. goto 5
    Then, when everything worked (sort of), I renamed some stuff so that 'konqueror' is konqueror 4 (I think having it konqueror 3 broke something else, but I don't remember what), and konqueror 3 is called 'k3nqueror'.
    If KDEmod3 ever goes away and there's no other good replacement file manager by then, I'll probably take the source code of KDE3 and try to make a standalone version of konqueror out of it. (Which will probably be quite a project because of how interdependent all the KDE components are.)
    Some features I "need" in a file manager, besides the ones you mentioned:
    - Konqueror's tree view (where you can expand folder branches in the file list)
    - Infinite view splitting -- I frequently have my konqueror windows split into 4, sometimes as many as 6 or 7 view panes. Very useful for sorting out files.
    - Selection rectangles are sensitive only over files -- I find full-row-select really annoying, because there are no guaranteed "blank" areas that you can click on to clear a selection. I also use this behaviour to grab long-named files that are interspersed with short ones, because they hilight first when the rectangle touches them (you wouldn't think this very useful, but surprisingly often you do want to do something to all the long-named files...)
    - Right-clicking on a folder and clicking "Paste" pastes into that folder, not the current one -- you'd be amazed at how many file managers get this wrong. I shouldn't have to cd into a folder just to paste some files there.

  • How To Search For a Text In JTable Column?

    hi there
    i want to search for specific text in a JTable Column
    And If The Text Exists Highlits it?
    any ideas or useful links or tutorials?

    Well, then that would be a Swing related question. Did you search the Swing forum to see how rendering works.

  • Crystal Report Viewer Closes the application after showing "The text cannot be found in the report" when searching for a text in a multipage report

    Post Author: Farooque
    CA Forum: Other
    Hi,
    I am using Crystal report viewer (Crviewer.dll) version 11.0.0.1282 to show crystal reports in my VB6 application. When we search for any text in a multipage report after the last find system shows a message "Crystal Report Viewer" "Text cannot be found in the report" and trows an unhandled error and closes the application. How can I fix this?
    Please help
    Thanks in advance.
    Farooque. ([email protected])

    Enter the following:
    viewer blank net crystal
    into the search box in the top right corner. You should get a number of hits (Kbases and articles) that should point you to a solution.
    Ludek
    Follow us on Twitter http://twitter.com/SAPCRNetSup
    Got Enhancement ideas? Try the [SAP Idea Place|https://ideas.sap.com/community/products_and_solutions/crystalreports]

  • How Can I stop Elements 7 from searching for a memory file?

    Recently, every time I turn on Elements 7 it starts searching for a missing file each time it encounters a photo with a "?" in the corner. I must have pressed a key somewhere to start this function but now I can't get it to stop. I can only continue to another photo if I press cancel while it is searching but I have to do this for each "?" marked picture. Is there any way of cancelling this feature? Thanks in anticipation.

    Two solutions:
    1. Uncheck the option Edit > Preferences > Files > Automatically Search For And Reconnect Missing Files.
    2. Either reconnect the missing files or delete them from the catalog, using the File > Reconnect > All Missing command.  See this FAQ for tips on how to use the command:
    http://www.johnrellis.com/psedbtool/photoshop-elements-faq.htm#_Quickly_reconnecting_large
    Leaving missing files in your catalog doesn't have any benefit.

  • When I open iMovie, the app searches for missing iPhoto files.  These are files I deleted.  I have to close about 30 dialog boxes before I can start using iMovie.  How do I make this stop?

    When I open iMovie (09), the app searches for missing iPhoto files.  These are files I deleted.  I have to close about 30 dialog boxes before I can start using iMovie.  How do I make this stop?

    So it seems the issue is when iMovie is wanting to creat thumbnails, if I ask it to ignore then it's fine but if not it hangs up searching for the video file.

  • Working on a script to search for and move files - need Guru help!

    Hi, I'm trying to help my dad with a task and my outdated Applescript knowledge isn't helping me much.
    Here's what I need to do in a nutshell:
    FolderA contains a bunch of JPG files.
    FolderB is the root of a hierarchy of folders containing DNG files.
    Each file of FolderA has a mating file (same name but with .DNG) somewhere in the hierarchy of FolderB.
    The goal is to move each JPG file from Folder A to the folder containing it's mate.
    So, the basic flow is:
    1. Get list of files in folderA
    2. Looping through list, strip out file name (fileA) and find the DNG file somewhere inside FolderB
    3. Get the path of the folder containing the matching DNG file
    4. Copy/move FileA to the folder.
    5. Loop back to #2
    OK, so here's where I am:
    tell application "Finder"
    set JPEGfolder to "Macintosh HD:DadTest1:DadA"
    set DNGfolder to "Macintosh HD:DadTest1:DadB"
    set a_list to every file in Afolder
    repeat with i from 1 to number of items in a_list
    -- Everything happens within this loop
    set a_file to (item i of a_list)
    set fileInfo to info for a_file
    set theName to displayed name of fileInfo as string
    -- now theName contains the actual file name minus the extension
    At this point I don't know how to search for the mating file using Applescript. If I was in UNIX I could do a "find . -name filename" and parse out the path, but I don't know how this works in Applescript.
    I think I can figure out how to move the file once I have the path, but the search routine has me stumped for now.
    Any thoughts?
    Thanks!

    In my opinion your best bet is to take a 180° turn and simplify things significantly.
    Your current approach involves multiple file searches - for each file in the JPEG folder, search all the DNG folders looking for a match. That's an large number of searches, and a large number of something that AppleScript isn't great at.
    Instead you'd be far better off walking once through the DNG folders. For each DNG file look for a matching JPG file in the one folder that contains JPEGs. This would be exponentially faster - one walk through the filesystem vs. one walk through the filesystem for every JPEG.
    This should give you an idea of what I'm talking about (untested):
    global JPEGfolder
    on run
      set JPEGfolder to alias "Macintosh HD:DadTest1:DadA"
      set DNGfolder to alias "Macintosh HD:DadTest1:DadB"
      processAFolder(DNGfolder)
    end run
    on processAFolder(theFolder)
      tell application "Finder"
        repeat with eachItem in folder theFolder
          if class of eachItem is file and name extension of eachItem is "dng" then
            set basename to characters 1 through -5 of (get name of eachItem)
            try
              move file (basename & ".jpg") of folder JPEGfolder to folder theFolder
            end try
          else if class of eachItem is folder then
            my processAFolder(eachItem)
          end if
        end repeat
      end tell
    end processAFolder
    The idea here is that you start off in the top folder and iterate through each item. If the item is a file and it's name extension is DNG then try to move a corresponding file from the JPEG folder to the current folder. This is wrapped in a try block so the script doesn't fail if there is no corresponding JPG.
    If the current item is a folder then the script descends into that folder by calling itself.

  • Search for any text in column filter on adf table

    Hi,
    I have column filter on adf table where I can search for any text starting with by default.
    For e.g. you have data my name is sam you can search on table column filter by my and you get the results my name is sam
    but I want to search by any word let's say sam and I want to display same result.
    Thank you,
    Savan Shah.

    You probably can use wildcards (% and _ )
    for example %my%
    Dario

  • My group box is causing problems when searching for a text line in a text file.

    I am developing a booking system, so for this I need to ensure that no two clients can book the same appointment slot. So, on testing my code which prevents double booking, the system doesn't seem to find the text line being searched for in the text file
    when it (purposefully) should.
    I have tried isolating the problem using breakpoints, and I've found that when the 'SearchLine' (referring to my code below) does not include the 'TimeComboBox.text' piece and instead this value is written into the code, the system is able to find the SearchLine
    without any problems. But, when assigning the group box's value to a variable and using this in the SearchLine instead, or without even using a loop and just doing a simple line by line search, the program can't find this line of text in the file.
    I'm lost for ideas. I have tried everything I can think of. Could anyone make any suggestions as for what is the problem with my group box? (I'll explain the code beneath it).
    'Setting the value of the SearchLine (which is a String)
    SearchLine = String.Concat(DateTimePicker1.Value.Date & " " & TimeComboBox.text)
    Dim FoundApp As Boolean
    Dim objReader As New System.IO.StreamReader(basicfilepath & "Text Files\Client Booked Appointment DatesTimes.txt")
    FoundApp = False
    'Reading the file's contents and checking for the SearchLine
    Do While (objReader.Peek() <> -1) or (FoundApp = True)
    If (TextLine = SearchLine) Then
    'Line contains SearchLine. Appointment already exists.
    FoundApp = True
    Else
    'Line doesn't contain SearchLine. Carry on searching.
    Msgbox("Line not found.")
    End if
    Loop
    Explanation
    When the line is searched for, the 'FoundApp' value must be set to 'True' when it is found. If it is not found, it remains false.
    To isolate the problem, I've displayed the SearchLine in a message box in the past to make sure that the correct line of text is being searched for.
    In basic terms, my program is searching for the exact line of text which exists in the text file, but for some reason it is not coming up as 'Found'. The error occurs when the group box's value is used. The text file which is being read is
    definitely correct. Please help, any suggestions would be appreciated.
    Thank you

    Hi
    It would appear that your snippet doesn't actually read the file at all.
    Here is my test which works fine.
    Option Strict On
    Option Infer Off
    Option Explicit On
    Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
    Dim SearchLine As String = "18:09:38 : XTaskSettings.Load PARAMS: begin"
    Dim FoundApp As Boolean = False
    Dim TextLine As String = Nothing
    Dim objReader As New IO.StreamReader(Application.StartupPath & "\Data\Report Q1.txt")
    FoundApp = False
    Do While (objReader.Peek() <> -1) Or (FoundApp = True)
    ' this was missing
    TextLine = objReader.ReadLine
    If (TextLine = SearchLine) Then
    'Line contains SearchLine. Appointment already exists.
    FoundApp = True
    MsgBox("Line found.")
    Else
    'Line doesn't contain SearchLine. Carry on searching.
    MsgBox("Line not found.")
    End If
    Loop
    End Sub
    End Class
    Regards Les, Livingston, Scotland

  • HT201285 Is there a way to search for deleted texts on the iphone 5c?

    Can I recover texts I have deleted?

    Yeah, but 1Password charges for both the iPhone client AND the Mac/Windows client, and it ain't cheap! Plus, it only syncs via Dropbox, and where I work Dropbox is banned due to security concerns.
    Sure, there is Secure Notes, a free form entry part of 1Password, but a bug in the program will not let you view all the text you can put in the field!! You have to EDIT the text to see the whole list! What if you accidentally delete or change an entry while scrolling through your entries??
    Plus NONE of the programs I have tried, and I have tried a lot, can find text IN the file - do a search and it will tell you what file/folder the text is in, but YOU have to scroll down through 400 entries one at a time looking for the entry.
    I use a program called Secure Text - I have many admin passwords, and DO not need a field based program. Secure Text is totally freeform entry. However, it suffers from the same search issue.
    If someone knows of a secure text program that uses a file/folder type of layout, free form entry, AND can actually tell you where in the file/folder the text you searched for is, PLEASE let me know! Plus sycing via some method other than Dropbox would be a plus.
    Before I got my iPhone, I used a program called Tombo for my WinCE based system AND my Windows workstation, and the synced up fine without iTunes, internet, DropBox type functionality or any of that horsecoller stuff Apple likes to throw on your neck.

  • Search for a text in document

    How do I search for a particular text and find the number of occurence of this text in a text file?

    try this example using regular expressions.
    public class Test {
    public static void main(String[] args) {
         Pattern p = Pattern.compile("(test)");
         Matcher m = p.matcher("test asjd flkjasd kfjasd klftest asld?kjfaslkdftest aaaaab");
         int count = 0;
         while(m.find()) {
              count++;
         System.out.println(""+ count);

  • Write diadem search results to text file

    Is there a solution within DIAdem for exporting specific information from a search result into a text file? For example: I perform a search which returns all of the files, groups, and/or channels which I want to work with; now I would like to have, say, the file paths of all the results of my search exported to a text file. Is this possible? I could not find a direct way of doing this, but perhaps a script already exists for doing stuff like this?

    Hi mrclary,
    I did not have this code handy, but I was able to whip it up for you.  Let me know if you have any questions.
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments
    Attachments:
    Search Result Paths.zip ‏1 KB

  • How to search for all PDF files on my hard drive

    How can I search for all of a file type on my hard drive without getting documents that happen to have the text in them?  i.e. PDF or DOC or XLS
    Thank you
    Peg

    Put the search term in quotes, and do not forget the .  (dot)
    Results (partial list) of Spotling search for ".pdf". There is a section listing PDF documents.

  • Search word in text file

    Hello,
    someone can help me with code?
    How to search in text file any word and count how many it were repeated?
    For example test.txt:
    hi
    hola
    hey
    hi
    bye
    hoola
    hiAnd if I want to know how many times are repeated in test.txt word "Hi" program must say "3 times repeated"
    I hope you understood what I want, thank you for answers.

    This is my code now.
    package lt.kvk.i3_2.test;
    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.io.IOException;
    import java.util.Scanner;
    public class Testing {
              public static void main(String args[]) throws Exception {
                   Scanner input = new Scanner(System.in);
                System.out.println("Select word from list:");
                System.out.println();
                try {
                        FileReader fr = new FileReader("src/lt/kvk/i3_2/test/List.txt"); // this is list of words, everything all right here
                        BufferedReader br = new BufferedReader(fr);
                        String s;
                        while((s = br.readLine()) != null) {
                             System.out.println(s);
                        fr.close();
                        String stilius = input.nextLine();   // eneter word which I want to count in File.txt
                    BufferedReader bf = new BufferedReader(new FileReader("src/lt/kvk/i3_2/test/File.txt")); // from this file I need to count word which I entered before
                    int counter = 0;               
                    counter = counter + 1;
                    counter++;
                    counter += 1;
                    String line;
                    System.out.println("Looking for information");
                    while (( line = bf.readLine()) != null){
                    int indexfound = line.indexOf(stilius);
                    if (indexfound > -1) {
                    System.out.println( "At all words which You want to count are "+ counter);
                    bf.close();
                catch (IOException e) {
                    System.out.println("Error");
              }         Here example of file.txt:
    test
    tea
    tree
    test
    car
    wind
    dog
    test
    car
    sea
    tea
    testIf I enter for example word "test" or any from this list I got answer:
    Looking for information
    At all words which You want to count are 3But it must to count how many times in this file this word are repeated, it must be 4
    if I enter word car It must show 2....
    And if I enter word which isn't in list (file.txt)
    Program didn't show error, just:
    Looking for informationThanks for answers.

Maybe you are looking for

  • How to sort out your problems with the os 4 upgrade.

    I'm in the UK, and I am an Orange customer. I have just been in contact with an amazing guy called Lee, who has sorted my problem for me. His advice....... go into Settings, general, scroll down to bottom of the screen to Reset, and tap on it. Go to

  • Check box in ALV grid gets unselected for new selection

    Hi all, This is my code : TYPE-POOLS : slis. Variable DATA: g_repid LIKE sy-repid,       g_title TYPE lvc_title,       g_set_pf_stat TYPE slis_formname VALUE 'SET_PF_STATUS',       g_user_command TYPE slis_formname VALUE 'USER_COMMAND',       g_layou

  • Custom image extension

    Can I give custom extensions to my image file? I want to secure my image file such that it can only be opened by my application. Is that even possible?

  • Modelling Collaborative BPM across Value Chain Evaluation of Approaches

    Question: Which approach is easy for modelling Collaborative BPM across value chain A) Centralise, B.) Decentralise, and C) Peer to Peer approach for?  What are the pros and cons?  What are the other important factors related with each approach? Expl

  • Using mail in Shell script

    Hey guys, I am writing a shell script to parse some data and create a csv file when done.  I want to be able to email the csv file when the script is done.  I cannot seem to figure out how to do this. I am running Mountain Lion and I have tried mail