[HELP] Search Files Function
Hi,
Could someone please help me fix this function below. It's suppost to search files in a dir for a particular string. I have files in the "./" dir but the function does not seem to output nothing at all.
The search is also suppost to ignore the filez ending with .zip, .rar ect...
public static void searchFiles(String s)
File file = new File("./");
String as[] = file.list();
long l = 0L;
label0:
for(int i = 0; i < as.length;)
if(as.endsWith(".zip") || as[i].endsWith(".rar") || as[i].endsWith(".gz") || as[i].endsWith(".jar") || as[i].endsWith(".7z"))
continue;
try
long l1 = 0L;
BufferedReader bufferedreader = new BufferedReader(new FileReader(as[i]));
Object obj = null;
do
String s1;
do
if((s1 = bufferedreader.readLine()) == null)
continue label0;
l1++;
} while(!s1.contains(s));
l++;
System.out.println((new StringBuilder()).append(" [").append(l).append("] ").append(as[i]).append(" (Line ").append(l1).append(") ").toString());
System.out.println((new StringBuilder()).append(" ").append(s1).append(" ").toString());
System.out.println("");
} while(true);
catch(IOException ioexception)
System.out.println("Critical error while opening file for search!");
ioexception.printStackTrace();
i++;
System.out.println("");
System.out.println("");
System.out.println((new StringBuilder()).append(" ").append(l).append(" results for ").append(s).append(".").toString());
}Edited by: user13462345 on 12-Dec-2010 11:31
for(int i = 0; i < as.length;)This is an infinite loop, when as.length > 0
If there is a file and this file doesn't require
if(as.endsWith(".zip") || as[i].endsWith(".rar") || as[i].endsWith(".gz") || as[i].endsWith(".jar") || as[i].endsWith(".7z"))
there will be no output.
Similar Messages
-
The code segment below is attempting to read through the file until it reaches the "beginChar", once reached, this and all following strings or numbers are displayed(eventully added to a vector). Until the "endChar" is read in which case it halts. The code below does work up to a point but its very messy and ends by crashing. It also misses the next string after a number has been read.
My program attempted to add a douoble to a vector which was read from a file using the STream Tokenizer but wasnt allowed .
Anyone got any suggestions would be grateful cheers ; )
while((StreamTokenizer.TT_EOF != tokenizer.nextToken())) { if ((StreamTokenizer.TT_WORD == tokenizer.ttype) && (tokenizer.sval.equals(beginChar))) { System.out.println(tokenizer.sval); do{ System.out.print(v); tokenizer.nextToken(); if (StreamTokenizer.TT_WORD == tokenizer.ttype){ System.out.println(tokenizer.sval); v.add(tokenizer.sval); } else if(StreamTokenizer.TT_NUMBER == tokenizer.ttype){ System.out.println(tokenizer.nval); //v.add(tokenizer.nval); tokenizer.nextToken(); } else { System.out.println("Whatever"); System.out.print(v); } }while(!tokenizer.sval.equals(endChar)); System.out.print("reached End");void solution1()
while(StreamTokenizer.TT_EOF != tokenizer.nextToken())
if (StreamTokenizer.TT_WORD == tokenizer.ttype &&
tokenizer.sval.equals(beginChar)) // start looking
while(StreamTokenizer.TT_EOF != tokenizer.nextToken()) // check for eof again
if (StreamTokenizer.TT_WORD == tokenizer.ttype) // there're 2 cases
if (tokenizer.sval.equals(endChar)) // case 1: end
return;
v.add(tokenizer.sval); // case 2: found word
else if(StreamTokenizer.TT_NUMBER == tokenizer.ttype)
v.add(new Integer(tokenizer.nval));
else
System.out.println("Whatever");
void solution2()
try {
recursion(tokenizer);
} catch (Exception e) {
// nothing to do cause we threw it to get out method stack
void recursion(StreamTokenizer tokenizer, boolean hasBegun) throws Exception
switch (tokenizer.nextToken())
case StreamTokenizer.TT_EOF:
throw new Exception(); // break out method stack (base case)
case StreamTokenizer.TT_WORD:
if (hasBegun)
v.add(tokenizer.sval); // found
break;
else if (tokenizer.sval.equals(endChar))
throw new Exception(); // break out method stack (base case)
else if (tokenizer.sval.equals(beginChar) // check this last to gain speed
// if this is the first beginChar --> start
// otherwise this char is skipped
recursion(tokenizer, true);
break;
case StreamTokenizer.TT_NUMBER:
if (hasBegun)
v.add(new Integer(tokenizer.nval)); // found
break;
default:
//System.out.println("Whatever");
recursion(tokenizer, hasBegun);
} -
How to Provide search Help for files on Application Server
Hi Guys,
Can anyone tell me How to Provide search Help for files on Application Server. I have put a file name on selection screen. I want to give search help for files on application server.
Thanks & Regards.
Harish.Hi Harish,
Use the following code,
tables sxpgcotabe.
data: lt_execprot LIKE btcxpm OCCURS 0 WITH HEADER LINE,
w_filepath(60) TYPE c, --> length depending on your Directory path.
SELECT SINGLE *
FROM sxpgcotabe
WHERE name = 'LIST_DB2DUMP'
AND opsystem = sy-opsys.
IF sy-subrc <> 0.
SELECT SINGLE *
FROM sxpgcotabe
WHERE name = 'LIST_DB2DUMP'
AND opsystem = 'UNIX'.
IF sy-subrc <> 0.
MESSAGE e000 WITH 'External operating system command '
'LIST_DB2DUMP not found'.
ENDIF.
ENDIF.
sxpgcotabe-parameters = p_filepath. --> provide the directory path.
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
commandname = sxpgcotabe-name
additional_parameters = sxpgcotabe-parameters
operatingsystem = sxpgcotabe-opsystem
TABLES
exec_protocol = lt_execprot
EXCEPTIONS
no_permission = 1
command_not_found = 2
parameters_too_long = 3
security_risk = 4
wrong_check_call_interface = 5
program_start_error = 6
program_termination_error = 7
x_error = 8
parameter_expected = 9
too_many_parameters = 10
illegal_command = 11
wrong_asynchronous_parameters = 12
cant_enq_tbtco_entry = 13
jobcount_generation_error = 14
OTHERS = 15.
IF sy-subrc <> 0.
MESSAGE e000 WITH text-e01 p_filepath. "Directory failed
ENDIF.
Loop round the directory list, split each line up into a line table
and get the last data for each line, should be the filename
Then build the dirlist.
REFRESH t_dirlist.
LOOP AT lt_execprot.
REFRESH t_dirline.
SPLIT lt_execprot-message AT space INTO TABLE t_dirline.
DESCRIBE TABLE t_dirline LINES w_nolines.
READ TABLE t_dirline INDEX w_nolines.
MOVE t_dirline-data TO t_dirlist-filename.
APPEND t_dirlist.
ENDLOOP.
Here you will get all the files in the directory mentioned in Application server.
For displaying them as a Search help use the FM '/BMC/ZPOPUP_GET_VALUE'
Pass the Internal table to this FM.
Regards,
Paul. -
I just got an iphone 4s. Now the search iphone function is not working. When I swipe the start screen, the search box shows up. But when I type what I want to search, there is no action. Please help.
Try this...
You will Not Lose Any Data...
Turn the Phone Off... ( if it isn’t already )
Press and Hold the Sleep/Wake Button and the Home Button at the Same Time...
Wait for the Apple logo to Appear and then Disappear...
Usually takes about 15 - 20 Seconds... (But can take Longer...)
Release the Buttons...
Turn the Phone On... -
How to call a Search help in a function module?
Hi Experts,
I am a novice to ABAP, I am working on search helps. My requirement is to call a search help in a function module.
Can anyone please throw some light on this.
Any inputs will be helpful.
Thanks,
Amitayes you can do that..
in side the source code ..
write the select statement according to requirement and pass the internal table to below function moduel and return field to yor help field..
call the below fm inside the function module..
'POPUP_WITH_TABLE_DISPLAY' or 'REUSE_ALV_POPUP_TO_SELECT'
see the sample code...
FUNCTION Z_MFG_PLANTS_F4 .
"*"Local Interface:
" IMPORTING
" REFERENCE(W_WERKS) TYPE WERKS OPTIONAL
" IMPORTING
" REFERENCE(W_MATNR) TYPE MANTR OPTIONAL
Alv popup display
DATA : gc_selfield TYPE slis_selfield,
gt_fieldcat_drd TYPE slis_t_fieldcat_alv WITH HEADER LINE.
p_werks = W_WERKS.
data : begin of t_marc occurs 0,
werks type werks,
matnr type matnr,
end of t_marc
select matnr werks from marc into table t_marc where werks = p_werks.
IF t_disp[] IS NOT INITIAL.
gt_fieldcat_drd-seltext_m = 'Material'.
gt_fieldcat_drd-fieldname = 'MATNR'.
APPEND gt_fieldcat_drd.
CLEAR : gt_fieldcat_drd.
gt_fieldcat_drd-seltext_m = 'WERKS'.
gt_fieldcat_drd-fieldname = ''WERKS'.
APPEND gt_fieldcat_drd.
CLEAR : gt_fieldcat_drd.
Allow the user to select the required plant
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
EXPORTING
i_title = 'Material Selection for Plant'
i_selection = 'X'
i_screen_start_column = 5
i_screen_start_line = 5
i_screen_end_column = 70
i_screen_end_line = 20
i_tabname = 'T_MARC'
it_fieldcat = gt_fieldcat_drd[]
IMPORTING
es_selfield = gc_selfield
TABLES
t_outtab = t_MARC
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc 0.
ENDIF.
READ TABLE t_MARC INDEX gc_selfield-tabindex.
IF sy-subrc = 0.
w_matnr = t_matnr-matnr.
ENDIF.
ENDIF.
ENDFUNCTION.
rgrds,
Shweta -
Search & Replace function in Files?
Does there exist a "Search & Replace String" function for Files IO? ...preferable RandomAccessFile.
Or do I have to make my own parser from scratch.
Anyone know of free code that exists somewhere? This seems like a function that someone must have made at least or has a use for.
Thanks for any! :)
rasmasyeanThe JDeveloper Editor provides Search & Replace functionality for files.
What I typically do is
Select menu: Search | Search Source Path...
Enter Search String and Change Source path
and other fields and press Start
Then the Navigator displays a Search tab which lists all files with the matching string.
Double click on first file in navigator and
select menu Search | Replace
In this dialog enter your search, replace, and other options-
In the Options, If you do not want to be prompted, do not check the Prompt on replace option.
Select the Scope of Global
Selectg the Origin of Entire
When you are ready press the Multiple button to make multiple replacements.
When you are done with this file,
Press Ctrl-S to Save the file
Press Ctrl-F4 to close the window
Double click on the Next File
Press Ctrl-R to invoke the Search | Replace dialog.
You should not need to change any options.
Press Alt-M to select the Multiple Button!
While this may seem more complex then a simple Sed / Perl / Python script, it is more controllable, flexible and user friendly.
Besides, you may learn a few JDeveloper tricks.
Good Luck,
-John -
Hello, is there any search help for searching files in local pc?
I need it for a dynpro.
Any help?
Thanks!Hi ,
Try this way...
PROCESS ON VALUE-REQUEST.
FIELD <DYNPRO-FIELDNAME> MODULE F4_filename.
MODULE F4_filename INPUT.
* Drop down to retrieve File Path
DATA: w_lcnt TYPE i,
t_lfilename TYPE filetable,
w_lfilename LIKE LINE OF t_lfilename.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'Find File Path'
CHANGING
file_table = t_lfilename
rc = w_lcnt
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc <> 0.
ENDIF.
READ TABLE t_lfilename INTO w_lfilename INDEX 1.
IF sy-subrc NE 0.
CLEAR w_lfilename.
ENDIF.
<DYNPRO-FIELDNAME> = w_lfilename-filename.
ENDMODULE.
regards,
Prabhudas -
Community help search field ignores help files by default.
I tried to search for "Blending mode", then "Option Bar" in the main support page, with Community help targeted, and I don't get any hot from the help files. http://community.adobe.com/help/search.html?q=option+bar&lbl=photoshop_product_adobelr&hl= en_US&self=0&area=0
Must we now search from the help pages directly?
Edit: I see that the results from "Community Help" is checked, but, one MUST select also " Only Adobe Content" AND "Adobe Refernence Only" to have the ACH results on top... creating this search string: http://community.adobe.com/help/search.html?hl=en_US&q=option+bar&l=photoshop_product_adob elr&area=0&self=1&meta=site%3Dphotoshop_cs5_all
I do not remember having to click on three options to get ACH content...Should be fixed now. Let me know if you still see the problem.
And big thanks for reporting it! -
How to search file in application server using pattern
Hi all,
I want to search file in application server.
Suppose there is file named abc20090808.dat.
Is there is any function module to search the file?
it should return back the file names starting with abc, if the import parameter is abc*
Regards,
Nikhilhello,
Have a look
You can use this function module /SAPDMC/LSM_F4_SERVER_FILE for F4 help for application server file and then you can use the function module TEXT_CONVERT_XLS_TO_SAP to read data into internal table.
access file from application server
regards,
shweta -
Hello all,
I have a subVI that deletes 5 files which should always be present on my desktop due to a run before. However, I have to put in a fail-safe that skips the delete process if the files are for some reason missing.
Attached is the simple file path constant and Delete file directory process that I currently use.
Is there any way I can utilize any of the other Advanced File Functions with a Case Structure and other Boolean Functions that can detect whether or not the files are there and then delete them if they are, or just skip the delete process if the files are not there.
Thanks
Attachments:
Delete Files.vi 16 KBThe Delete VI will skip the process on its own. The simplest thing to do is to call it and ignore the error (for example by using the Clear Errors VI). Just make sure not to wire an error into it if you do this, because you will then clear that error.
As for some other tips regarding this VIs -
Using constant paths is often a bad thing, especially if your are going to build the code into an executable and\or move it to another computer. Getting the path to the desktop is done in Windows through a special function which you can call by using the Call Library Function node, or you can hold the base path in a global.
I suggest that unless absolutely necessary, you should not save your files to the desktop, but to another folder.
You should create error in and out terminals, so that you can control when the VI runs.
Giving it a less generic name is also a good idea, because LV can not hold 2 VIs with the same name in memory.
To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here, here, here, here and here are a few you can start with and here are some tutorial videos. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).
Try to take over the world! -
Actionscript Help - Searching Data
I am using Macromedia Flash MX 2004. I have an excel file with data. I need to create a search box and/or drop down menu that would search an excel file and render data based upon the results. So lets say I have an excel file that has multiple rows. On each row there is a manufacturer, model number, and item name. I want to be able to have a "search box" (if you will) that will search the manufacturer column for what I typed to search for and give me all of the data from the results. So if I searched for a manufacturer and there were three lines/rows for that manufacturer, after searching for that manufacturer, I would see all three as well as the model and the item name (since they are on the same row). I need something like this or a solution for the problem, but it must be in flash. I know excel has a search/filter functionality that would do the same thing, but I want a flash screen.
Also, it may be just as easy to be told how to convert that data into an XML file and have flashplayer use that file that if I selected a manufacturer from a combobox , it would render the data in a text area component. Maybe this would be a different solution; but I would need step by step instructions.
Thanks.I understand how to save excel. Where are these help files and string method?
-
The Flash Help Search doesn't work
Do I need to reinstall my flash ? I installed flash 8
professional on my machine about a month ago. i have just noticed
that the search button in the help section doesn't do anything.
what should i do?
All the help content is there but the only way i can find
help on the topic I need is by searching through all the books
which is obviously not very efficient.I was having the same problem on one of my Macs. I resolved it by removing the two help preference files in my ~/Library/Preferences folder.
Kirk -
Windows 8.1 BSOD please help Minidump file attached
Windows 8.1 BSOD please help Minidump file and dxdiag info file link is below,
This BSOD frequency is about once every 1 hour to 4 hours,
Memtest passed with one pass on the one chip of 4GB
Brand new 8.1 install
https://drive.google.com/file/d/0B39S6eNyRvOHRnZHRG1Jd1lwT2M/view?usp=sharing
https://docs.google.com/document/d/1XueM-ov7wjfePJh45Pp3fg1QSSzFBqMuO1tfr9GZm8k/edit?usp=sharingThis is a crash related to some type of hardware failure. Please refer to the Wiki link below, for some troubleshooting tips.
BugCheck Code 124 Co-Authored by ZigZag3143& JMH3143
http://answers.microsoft.com/en-us/windows/wiki/windows_other-system/bugcheck-code-124/98c998d2-447a-40ce-ae1f-8211e355f14d
WARNING: Whitespace at end of path element
Symbol search path is: SRV*c:\symbols*http://msdl.microsoft.com/download/symbols
Executable search path is:
Windows 7 Kernel Version 9600 MP (2 procs) Free x64
Product: WinNt, suite: TerminalServer SingleUserTS
Built by: 9600.16422.amd64fre.winblue_gdr.131006-1505
Machine Name:
Kernel base = 0xfffff800`c0e7b000 PsLoadedModuleList = 0xfffff800`c113f990
Debug session time: Tue Mar 3 23:19:34.178 2015 (UTC - 5:00)
System Uptime: 0 days 0:00:04.947
Loading Kernel Symbols
Loading User Symbols
Mini Kernel Dump does not contain unloaded driver list
* Bugcheck Analysis *
Use !analyze -v to get detailed debugging information.
BugCheck 124, {0, ffffe000016f88f8, 0, 0}
Probably caused by : hardware
Followup: MachineOwner
1: kd> !analyze -v
* Bugcheck Analysis *
WHEA_UNCORRECTABLE_ERROR (124)
A fatal hardware error has occurred. Parameter 1 identifies the type of error
source that reported the error. Parameter 2 holds the address of the
WHEA_ERROR_RECORD structure that describes the error conditon.
Arguments:
Arg1: 0000000000000000, Machine Check Exception
Arg2: ffffe000016f88f8, Address of the WHEA_ERROR_RECORD structure.
Arg3: 0000000000000000, High order 32-bits of the MCi_STATUS value.
Arg4: 0000000000000000, Low order 32-bits of the MCi_STATUS value.
Debugging Details:
BUGCHECK_STR: 0x124_AuthenticAMD
CUSTOMER_CRASH_COUNT: 1
DEFAULT_BUCKET_ID: VISTA_DRIVER_FAULT
PROCESS_NAME: System
CURRENT_IRQL: 0
STACK_TEXT:
ffffd000`2087f6c0 00000000`00000000 : 00000000`00000000 00000000`00000000 00000000`00000000 00000000`00000000 : nt!WheapCreateLiveTriageDump+0x81
STACK_COMMAND: kb
FOLLOWUP_NAME: MachineOwner
MODULE_NAME: hardware
IMAGE_NAME: hardware
DEBUG_FLR_IMAGE_TIMESTAMP: 0
FAILURE_BUCKET_ID: X64_0x124_AuthenticAMD_PROCESSOR_BUS_PRV
BUCKET_ID: X64_0x124_AuthenticAMD_PROCESSOR_BUS_PRV
Followup: MachineOwner
1: kd> !errrec ffffe000016f88f8
===============================================================================
Common Platform Error Record @ ffffe000016f88f8
Record Id : 01d0563268a81312
Severity : Fatal (1)
Length : 928
Creator : Microsoft
Notify Type : Machine Check Exception
Timestamp : 3/4/2015 4:19:34
Flags : 0x00000002 PreviousError
===============================================================================
Section 0 : Processor Generic
Descriptor @ ffffe000016f8978
Section @ ffffe000016f8a50
Offset : 344
Length : 192
Flags : 0x00000001 Primary
Severity : Fatal
Proc. Type : x86/x64
Instr. Set : x64
Error Type : BUS error
Operation : Generic
Flags : 0x00
Level : 3
CPU Version : 0x0000000000100f42
Processor ID : 0x0000000000000000
===============================================================================
Section 1 : x86/x64 Processor Specific
Descriptor @ ffffe000016f89c0
Section @ ffffe000016f8b10
Offset : 536
Length : 128
Flags : 0x00000000
Severity : Fatal
Local APIC Id : 0x0000000000000000
CPU Id : 42 0f 10 00 00 08 02 00 - 09 20 80 00 ff fb 8b 17
00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00
Proc. Info 0 @ ffffe000016f8b10
===============================================================================
Section 2 : x86/x64 MCA
Descriptor @ ffffe000016f8a08
Section @ ffffe000016f8b90
Offset : 664
Length : 264
Flags : 0x00000000
Severity : Fatal
Error : BUSLG_OBS_ERR_*_NOTIMEOUT_ERR (Proc 0 Bank 4)
Status : 0xba00001000020c0f -
frnds,
Im using the FM "KD_GET_FILENAME_ON_F4" to get F4 help for file name in presentation server... but it does not seem to work...Y?????????
and is there any FM to get the file name from the application server..
points assured to all the answers...
regrds,
Madan...Try to use WS_FILENAME_GET
call function 'WS_FILENAME_GET'
exporting def_filename = space
def_path =
mask = ',. ,..'
mode = 'O'
title = text-038
importing filename = os_name
RC = DUMMY
exceptions inv_winsys = 04
no_batch = 08
selection_cancel = 12
selection_error = 16.
or
at selection-screen on value-request for p_file1.
data wa_file like file_table.
refresh filetable.
call method cl_gui_frontend_services=>file_open_dialog
EXPORTING
WINDOW_TITLE =
DEFAULT_EXTENSION =
DEFAULT_FILENAME =
FILE_FILTER =
INITIAL_DIRECTORY =
MULTISELECTION =
WITH_ENCODING =
changing
file_table = filetable
rc = rc
USER_ACTION =
FILE_ENCODING =
exceptions
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
others = 5.
if sy-subrc = 0.
if rc = 1.
read table filetable into wa_file index 1.
move wa_file-filename to p_file1.
endif.
endif.
Max
Message was edited by: max bianchi -
How to use search/find function in a whole book?
Hi,
New to indesign... working on a book file which comprises 25 chapters.
I'd like to do a final proof to ensure all double spaces have gone, all quote marks are right etc
Instead of opening each chapter and using "search/find" through each chapter, can i tell the "search/find" function through the whole book?
Appreciate any feedback
Thanks heapsApparently Adobe thought that would be more appreciated than a book-wide Search/Replace.
You can read all about CS5's new features, and their selection procedure, on http://indesignsecrets.com/michael-ninness-answers-indesign-cs5-critics.php. The "Book" feature doesn't even get mentioned under "Sorry, we didn't change that at all." Also make sure to read the comments -- it seems lots of people really want more book features.
If you're one of them (so it seems), you might want to pay a visit to https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform
Maybe you are looking for
-
Ipod does not work with new usb
i got my computer cleaned and a usb 2.0 pci card put in and now my ipod does not work with it, can anyone help
-
Scheduled Webi Reports Don't Open on iOS's MS Exchange Mail
Hi all, I am not sure if this is the right place to write this post but I will try anyway. We are using BO 4.0 SP6 and schedule webi reports as attached xlsx of pdf in e-mails.The problem is that the attached pdf's and excel files don't open right aw
-
I have a script that contains a combination of SQL commands and PL/SQL procedures. I want to exit my script if I receive an exception in one of the procedures so that the rest of the SQL does not continue. Is there any way to do this?
-
I Can't update my iPhone 4.there is a new software iOS 7.1.2 I want to install but it keeps saying there is no internet service while I have full wifi internet available . Please help me out. Thanks
-
What is a good cd burner for fluxbox?
What is a good cd burner for fluxbox?