Reading dynamically changing file
Hi all
I have a text file which is dynamic in nature, ie, every 1-30 minute(s) a line is appended to it.
I would be grateful if anyone helps me (may be with some sample code/link) in how I can get a notification regarding when the line is appended and how to get the last appended line(s).
Thanks in advance
Anjan
Run a thread to check the file every half hour or however often you like, then use java.io.File.lastModified(). Compare this long (representing a time) to the last time you checked it. If the new time is greater (more recent) than the last time you checked, the file has changed.
Similar Messages
-
Selecting dynamically changing file
Hi everyone
I'm creating a script that will copy the currently selected track from itunes to the desktop and import into iMovie. The following is what I have thus far:
-- check if itunes is open
tell application "Finder"
if (get name of every process whose visible is true) ¬
contains "iTunes" then
my convertSong()
else
display dialog ¬
"You have not selected a song from iTunes!" buttons ¬
"Cancel" default button 1 giving up after 10
end if
end tell
on convertSong()
-- dupe selected track
tell application "iTunes"
if selection is not {} then
set _location to get location of selection
else
display dialog "You have not selected a song from iTunes!" buttons ¬
"Cancel" default button 1 giving up after 10
end if
end tell
set _theSong to (choose file with prompt "Choose Song" default location _location)
tell application "Finder" to duplicate _theSong to "Macintosh HD:Users:OAC:Desktop"
delay 2
-- create new movie, import song from desktop.
tell application "iMovie HD"
try
open
end try
activate
tell application "System Events"
keystroke "n" using {command down}
delay 1
keystroke "iMovieSong"
delay 1
tell process "iMovie HD"
click button "Create" of window "Create Project"
end tell
delay 15
-- brings up the Import dialog from iMovie menu
keystroke "i" using {command down, shift down}
-- select file statements here
end tell
end tell
end convertSong
the problem is I don't know how to reference the duplicated song (which will be changing periodically). What kinds of statements will work in this situation?
thanks!Ahh, that's one of the vagaries of the Finder - it has its own unique way of referencing files.
There are two ways around it, one is to tell the Finder to open the file with a specific application:
tell application "Finder"
set theDupeFile to duplicate _theSong to "Macintosh HD:Users:OAC:Desktop"
open theDupeFile using application "iMovie"
end tell
the other is to coerce the result of the duplicate command to an alias, the universal file reference:
tell application "Finder" to set theDupeFile to duplicate _theSong to "Macintosh HD:Users:OAC:Desktop" as alias
That simple as alias on the end coerces the Finder reference to an alias which any other application should be able to handle. -
Grant an account rights to read and modify files in all Redirected Documents folders?
We have set up redirected Documents folder with the default recommended permissions that does not grant Administrators any access to the folders. If an administrator needs access to a folder, they take ownership of the folder, grants themselves permissions
and does whatever they need to do with the folder such as delete it or give access to a new person. This is rarely needed so it is not a big deal.
However, we now need to import everyone's Outlook PSTs (stored in their redirected MyDoc's so they are backed up) into their new Exchange Archive mailboxes. We will also need to be able to verify all PSTs are gone from the file server
once the contents are imported into their archive mailbox. We also need to be able to run reports showing which users are storing music and video files in their folders and how much.
When I tried to run Windirstat against the share containing the redirected MyDocs folders to see what file types where taking up space, I got very incomplete results even with using psexec running as system account due to inadequate permissions on the user's
folders.
We also need the PST Capture Tool to have rights to read into their documents folders and move any psts found into the users archive mailbox.
Rather than having to go to each user's redirected documents fiolder one by one and take ownership to change permissions, is there a more efficient way to have an account running the PST Capture Tool and WindirStat have access to read and change files in
the user's redirected documents folders?
I thought of just removing the option in the GPO that says "Grant the user exclusive rights to My Documents," but I don't think that will work on pre-existing
folders that already have permissions set.Hi,
Based on my research, if you already have a bunch of existing redirected My Documents folders set up with the
Grant the user exclusive rights to My Documents check box selected, the only documented way to regain access to the folders is to take ownership of each individual folder and manually edit the permissions to give the Administrators group full
control.
We can use powershell script to help regain access to the folders, for more details, please go through the below link:
http://mypkb.wordpress.com/2008/12/29/how-to-restore-administrators-access-to-redirected-my-documents-folder/
Regards,
Yan Li
Regards, Yan Li -
How read a pdf file and change TableCell height after reading it using itext api
I have created a pdf form file using itext ( see class CreatingFormClass ) with itext PdfPTable and PdfPCell. It is done successfully .
Now I read this pdf file and filling this pdf file(see class FillingFormClass ) and at this point i want to change PdfPCell height () according to Items.
It is possible or Not???
My code is given below.
Thanx in advance
public class FillPdfFormMainClass {
public static String RESULT1 = "E:/BlankForm.pdf";
public static String RESULT2 = "E:/FilledForm.pdf";
public static void main(String[] args) throws DocumentException, IOException {
String empName="Rakesh Kumar Verma";
// This part is Dynamic. It can be 1 item Or can be 25 items
String listOfItem="Item 1 \n Item 2 \n Item 3\n Item 4 \n Item 5 \n Item 6 \n Item 7 \n Item 8 \n Item 9";
CreatingFormClass example = new CreatingFormClass(0);
example.createPdf(RESULT1);
FillingFormClass class1 = new FillingFormClass();
class1.manipulatePdf(RESULT1, RESULT2,empName,listOfItem);
public class CreatingFormClass implements PdfPCellEvent {
protected int tf;
public CreatingFormClass(int tf) {
this.tf = tf;
public void createPdf(String filename) throws DocumentException, IOException {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream(filename));
document.open();
PdfPCell cell;
PdfPTable table = new PdfPTable(2);
table.setWidths(new int[]{1, 2});
table.addCell("Name:");
cell = new PdfPCell();
cell.setCellEvent(new CreatingFormClass(1));
table.addCell(cell);
table.addCell("Item List:");
cell = new PdfPCell();
cell.setCellEvent(new CreatingFormClass(2));
cell.setFixedHeight(60);
table.addCell(cell);
document.add(table);
document.close();
public void cellLayout(PdfPCell cell, Rectangle rectangle, PdfContentByte[] canvases) {
PdfWriter writer = canvases[0].getPdfWriter();
TextField text = new TextField(writer, rectangle, String.format("text_%s", tf));
text.setBackgroundColor(new GrayColor(0.95f));
switch (tf) {
case 1:
text.setText("Enter your name here...");
text.setFontSize(8);
text.setAlignment(Element.ALIGN_CENTER);
break;
case 2:
text.setFontSize(8);
text.setText("Enter Your Address");
text.setOptions(TextField.MULTILINE);
break;
try {
PdfFormField field = text.getTextField();
writer.addAnnotation(field);
} catch (IOException ioe) {
throw new ExceptionConverter(ioe);
} catch (DocumentException de) {
throw new ExceptionConverter(de);
public class FillingFormClass {
public void manipulatePdf(String src, String dest,String empName,String listOfItem) throws IOException, DocumentException {
PdfReader reader = new PdfReader(src);
PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(String.format(dest, empName)));
AcroFields form = stamper.getAcroFields();
form.setField("text_1", empName);
form.setField("text_2", listOfItem);
stamper.close();
reader.close();Hi,
I am facing the same problem. Please help me out. I just want to read a PDF file as bytes from one location and write it as another pdf file in some other location with a diolog box prompting to open or save in the location where we want.
I executed the following code:
try{
File report =new File(location);
BufferedInputStream in=new BufferedInputStream(new FileInputStream(report));
response.setContentType("application/x-download");
response.setHeader("Content-Disposition", "attachment; filename=" + report.getName());
OutputStream outs = response.getOutputStream();
int readlen;
byte buffer[] = new byte[ 256 ];
while( (readlen = in.read( buffer )) != -1 )
outs.write( buffer, 0, readlen );
outs.flush();
outs.close();
in.close();
response.setStatus(HttpServletResponse.SC_OK);
} catch (FileNotFoundException fileNotFoundException) {
PrintWriter out= response.getWriter();
out.print("<center><Font color = 'RED'><b>"+PxDSLUtils.getApplicationProperty("label.error.CTM_E017")+"</b></Font></center>");
Though it prompts with open, save dialog box when i try to open directly or when i save it some where locally and then open it i am getting the following message " File is repaired ot damaged.Operation failed." Any idea about what can be done??? Its very urgent.Please suggest.
I am not convetin to string just reading and writng as bytes itself.
Thanks in advance,
Mani -
Dynamic changes / init file?
Is there any way to bypass changing the init file to make a dynamic change?
I have to make a change for archiving, and I can't bounce the db right now.
10.2.0.3, HPUX itanium
changes that need to be made...
log_archive_config DG_CONFIG=(peregrine,swesc)
log_archive_dest_state_2 = DEFER
fal_client peregrine
fal_server swesc
I don't really want to just issue these at the command line unknowing if they would do as I want or cause adverse affects.
Is it possible to just rip the command, and update the file too? command line causing immediate change, and init file change will allow for keeping it when restarted...
Thanksalter system set <parameter> = <value>;defaults to memory assuming that they are immediately modifiable
otherwise
alter system set <parameter> = <value> scope = memory;should do the trick as well. You probably want to use a spfile that way you can do both at the same time:
alter system set <parameter> = <value> scope = both; -
I could previously view these files with no problem, I have all the latest versions of adobe and plug in installed, when I try and open a file it tells me adobe reader could not open the file I am trying to open because it is either not a supported file type or the file has been damaged. I don't understand what is going on and need access to these files. Can anyone help please?
I think you need to change your Windows Explorer settings to show the file extensions, then you can clearly see what file types you have.
Those with .doc / .docx extensions should show the blue Word icon.
Those with .pdf extensions should show the red Adobe Reader icon.
Those that do not need to fix the file association; see http://windows.microsoft.com/en-us/windows/change-file-open-program -
Read a CSV file and dynamically generate the insert
I have a requirement where there are multiple csv's which needs to be exported to a sql table. So far, I am able to read the csv file and generate the insert statement dynamically for selected columns however, the insert statement when passed as a parameter
to the $cmd.CommandText
does not evaluate the values
How to evaluate the string in powershell
Import-Csv -Path $FileName.FullName | % {
# Insert statement.
$insert = "INSERT INTO $Tablename ($ReqColumns) Values ('"
$valCols='';
$DataCols='';
$lists = $ReqColumns.split(",");
foreach($l in $lists)
$valCols= $valCols + '$($_.'+$l+')'','''
#Generate the values statement
$DataCols=($DataCols+$valCols+')').replace(",')","");
$insertStr =@("INSERT INTO $Tablename ($ReqColumns) Values ('$($DataCols))")
#The above statement generate the following insert statement
#INSERT INTO TMP_APPLE_EXPORT (PRODUCT_ID,QTY_SOLD,QTY_AVAILABLE) Values (' $($_.PRODUCT_ID)','$($_.QTY_SOLD)','$($_.QTY_AVAILABLE)' )
$cmd.CommandText = $insertStr #does not evaluate the values
#If the same statement is passed as below then it execute successfully
#$cmd.CommandText = "INSERT INTO TMP_APL_EXPORT (PRODUCT_ID,QTY_SOLD,QTY_AVAILABLE) Values (' $($_.PRODUCT_ID)','$($_.QTY_SOLD)','$($_.QTY_AVAILABLE)' )"
#Execute Query
$cmd.ExecuteNonQuery() | Out-Null
jyeragiHi Jyeragi,
To convert the data to the SQL table format, please try this function out-sql:
out-sql Powershell function - export pipeline contents to a new SQL Server table
If I have any misunderstanding, please let me know.
If you have any feedback on our support, please click here.
Best Regards,
Anna
TechNet Community Support -
How to read an xml file in OSB using file protocol where reading file path is dynamic.
HI,
We have to read a xml file from a location and write into Db.
Here reading file location is dynamic .
Please suggestHi
With open dataset you can open any file on the application server. So it should be working, but maybe you are looking for:
CALL TRANSFORMATION my_transformation
SOURCE XML xml_string
RESULT ROOT1 = field1
ROOT2 = field2.
Best regards,
Guido Koopmann -
Can I change the file path that itunes reads my music files from?
I have about 65000 music files that i have transferrd from my external to a new laptop internal HD.
I have organised the folders myself as I use a PC and do not want itunes to organise the folders because when I'm searching through music on windows it is sorted out by artists/albums with 'the...(eg The Beatles)' under 'T' instead of 'B'.
Long story short.... Is there any way that I can keep my itunes library as it is on the external HD and copy it to the new laptops C drive, keep all the info (playlists etc) and still have the same folder structure as on the external HD?
Or, is there any way of making windows sort things in alphabetical order like it is in itunes (eliminating the 'the' issue)?The files that weren't inside the media folder on the original machine need to be copied over to exactly the same paths as they had on the source machine. See this thread for an ongoing discussion of a similar problem. See also this post on migrating the iTunes library.
tt2 -
Read a csv file, fill a dynamic table and insert into a standard table
Hi everybody,
I have a problem here and I need your help:
I have to read a csv file and insert the data of it into a standard table.
1 - On the parameter scrreen I have to indicate the standard table and the csv file.
2 - I need to create a dynamic table. The same type of the one I choose at parameter screen.
3 - Then I need to read the csv and put the data into this dynamic table.
4 - Later I need to insert the data from the dynamic table into the standard table (the one on the parameter screen).
How do I do this job? Do you have an example? Thanks.Here is an example table which shows how to upload a csv file from the frontend to a dynamic internal table. You can of course modify this to update your database table.
report zrich_0002.
type-pools: slis.
field-symbols: <dyn_table> type standard table,
<dyn_wa>,
<dyn_field>.
data: it_fldcat type lvc_t_fcat,
wa_it_fldcat type lvc_s_fcat.
type-pools : abap.
data: new_table type ref to data,
new_line type ref to data.
data: xcel type table of alsmex_tabline with header line.
selection-screen begin of block b1 with frame title text .
parameters: p_file type rlgrap-filename default 'c:Test.csv'.
parameters: p_flds type i.
selection-screen end of block b1.
start-of-selection.
* Add X number of fields to the dynamic itab cataelog
do p_flds times.
clear wa_it_fldcat.
wa_it_fldcat-fieldname = sy-index.
wa_it_fldcat-datatype = 'C'.
wa_it_fldcat-inttype = 'C'.
wa_it_fldcat-intlen = 10.
append wa_it_fldcat to it_fldcat .
enddo.
* Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_fldcat
importing
ep_table = new_table.
assign new_table->* to <dyn_table>.
* Create dynamic work area and assign to FS
create data new_line like line of <dyn_table>.
assign new_line->* to <dyn_wa>.
* Upload the excel
call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'
exporting
filename = p_file
i_begin_col = '1'
i_begin_row = '1'
i_end_col = '200'
i_end_row = '5000'
tables
intern = xcel
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
* Reformt to dynamic internal table
loop at xcel.
assign component xcel-col of structure <dyn_wa> to <dyn_field>.
if sy-subrc = 0.
<dyn_field> = xcel-value.
endif.
at end of row.
append <dyn_wa> to <dyn_table>.
clear <dyn_wa>.
endat.
endloop.
* Write out data from table.
loop at <dyn_table> into <dyn_wa>.
do.
assign component sy-index of structure <dyn_wa> to <dyn_field>.
if sy-subrc <> 0.
exit.
endif.
if sy-index = 1.
write:/ <dyn_field>.
else.
write: <dyn_field>.
endif.
enddo.
endloop.
REgards,
RIch Heilman -
Java mapping - for reading the binary file contents and changing filename
Hi,
I have already gone through the various bolgs and threads and have not been able to find a solution to my problem.
One blog did give some idea but did not help- "JAAPPING", an alternate way of reading a CSV file
I am not very good in java but have been trying some out recently to fulfill the interface requirements.
I would really appreciate if you could help am I am giving below the detailed scenario below.
Part 1- working fine - The incoming file looks like:
:20:STMEMU096868DUBE
:25:001180256210
:28C:00371/00001
:60F:C090617AED742136,92
:61:0906300630CD34,27FINTCREDIT INTEREST
26MAY2009 TO 25JUN2009
:62F:C090630AED742171,19
:64:C090630AED742171,19
The file name as received is:TCDE.BLQSAM.SAEA2682.C0084025.A9G24T58.20090724195908
This file without any conversion is placed on XI server dircetory folder.
Part 2 - need to develop
The file should now be renamed according to the incoming value in 2nd line - specifically the 12 digit value 001180256210 and placed on the R/3 dircetory folder.
The new file name in the above example should be:
AC_NO_001180256210_datetime
The module for the above was created and the last time I checked it was working.
However, when I wanted to do final testing in Dev and move the changes further, the module has seemed to have stopped working so I need an alternate solution fast.
I was thinking of doing the Java mapping as I will be more in control as to what is going on thereby reducing the dependency.
There is no need to create any target xml structure as the file as it is needs to be placed in the target folder with a new name.
I can get the file name in UDF which I have already created but i am not usre if it working.
Can you please help?
Any help will be greatly appreciated.
Regards,
Archana
+44-7867636863Hi Stephen
The xml must be getting added in the below part of the code. It is coming from arg[0]
You can put a check and get it removed.
while ((len = arg0.read(buffer)) != -1) {
arg1.write(buffer, 0, len);
Regards
Osman -
Dynamically changing the name of the .dll file to load in call Library
Our current model is to use dll files as "plug-in" modules for instruments and a top layer test step calls the appropriate driver dll.
For instance
the TestStep is called with the kenmore.dll passed as a parameter so the kenmore.dll file is loaded, the functions are registered and the functions are called. Next the TestStep is called with whirlpool.dll as a parameter now the whirlpool.dll is loaded the functions are registered and the functions are called. This works very well in our current CVI/LabWindows environment. Now we plan to work with LabView, we wish to retain this model (as DLL files, there are advantages in our model for us). We have not found a way to load these dll files from LabView without hard coding the path and filenames in.
Any suggestions on how to dynamically change the path in the Call Library module, or another suggested method of loading the dll via LabView?
Thanks,John Stuart wrote:
Our current model is to
use dll files as "plug-in" modules for instruments and a top layer test
step calls the appropriate driver dll.
For instance
the TestStep is called with the kenmore.dll passed as
a parameter so the kenmore.dll file is loaded, the functions are
registered and the functions are called. Next the TestStep is
called with whirlpool.dll as a parameter now the whirlpool.dll is
loaded the functions are registered and the functions are called.
This works very well in our current CVI/LabWindows environment.
Now we plan to work with LabView, we wish to retain this model (as DLL
files, there are advantages in our model for us). We have not
found a way to load these dll files from LabView without hard coding
the path and filenames in.
Any suggestions on how to dynamically change the path in the Call
Library module, or another suggested method of loading the dll via
LabView?
Thanks,
As Ben has pointed out LabVIEW
scripting may be a possibility but you are going with that in highly
unsupported area. Also I happen to know that changing the library name
of a Call Library Node through scripting has produced unsupported
feature errors previous to LabVIEW 7.1 eventhough the method was there.
And LabVIEW 8 hides the whole scripting business behind the license
manager.
Another approach at least if the different DLLs do not change to often
thier functions and parameters would be to create a wrapper DLL. Have
it a method that loads the desired DLL and links its functions to
internal function pointers. Then when calling the actual function entry
points just redirect directly to the correct fucntion through that
function pointer. Since you are already working in CVI creating such a
DLL should be only a matter of taking out a little bit of your already
existing code and put it into a DLL project.
Rolf Kalbermatter
Message Edited by rolfk on 04-12-2006 07:40 AM
Rolf Kalbermatter
CIT Engineering Netherlands
a division of Test & Measurement Solutions -
Reading Dynamic Files using File port
Hello All,
We have a requirement in our project where we have to use File Port to pick a set of IDOC Flat files from a given directory. The File Port only allows us to pick a file with a specific given name and does not allow us to pull file with a pattern for .eg. We can pull a file abcd.txt but cannot pull something like abc.txt. Our requirement is to pull abc.txt using the File Port.
If anyone has any idea about this, or any past experience with File Port in this regard, then please respond at the earliest.
We have created the file port with follwoing parameters:
Unchecked the Unicode Format System Setting
For the Inbound File:
Function Module: EDI_PATH_CREATE_CLIENT_DOCNUM
Directory is: A valid directory path
File Name: abcd.txt
Thanks in advance.
AbinashIf the xml files are all in the same directory (not in any directory structure relative to the parent directory), you can do something like this.
- create a bpel process to read the zip files as it comes into the directory]
- Have a file adapter inbound for the receive
- Call windows .bat command within the bpel process to run an unzip command on that directory
- Have another bpel process that reads *.xml files and this will get kicked off.
There are so many ways of solving this: like having a cron job to unzip the files coming in etc. But, if you have a directory structure for these XML files and if the structure is dynamic, it is difficult to configure the file adapter for that. -
Hi, I godt 2 Questions: 1) My Adobe PhotoShop Elements 10.0 for MAC cannot read the RAW files taken with the new Canon 7D Mark II camera. 2) My Photoshop Elements has changed from the danish language to german language, how do I put this back ?
You're in the wrong forum. This is not the Elements forum.
Here's the link to the forum you want:
https://forums.adobe.com/community/photoshop_elements/content -
Lion administrator setting changed to read only for file sharing. Now hung machine
I was trying to network my Mac with a WIndows 7 machine and tried to have my name in the file sharing read write instead of other users such as administrator when I changed the administrator to read only for file sharing rights and could not add my name as a file sharing user with read write permissions Really silly move
I have performed a repair of disk permissions however still hung.
Whats worse is that my time machine for the last three days has been disconnecting when backing up leaving a partially complete backup. Backup failed. I also left a apple support community message a few days ago to solve it.
So its critical
Timely HELP is needed.This same problem happened to me, all the sudden one day my mac decided to revert to the original standard root username and password which I obviously did not know. In order to change this:
1) Activate single user mode on reboot as by pressing cmd + s as your computer starts up. Make sure you do it right away, and keep the keys pressed down.
2) Where the cursor pops up, type exactly
+/sbin/mount - uw/+
3) When the next cursor pops up type exactly
passwd
4) Then you can type any password you want (now changing the root password to be what you want)
Note you will not be able to see what you type, but the text is being recognized
5)The computer asks for you to retype the password, retype it
6) Type reboot
Once the computer restarts you can navigate to system preferences>accounts> and then unlock the account (lock is located on the bottom left corner) using Username: root and the password you just set. Henceforth, you can appoint your account as the administrator. Hope it works!
Maybe you are looking for
-
I have completed a factory system restore. After doing a complete factory reinstall the FF updater is not installing the latest updates. I get this error message: Error: Platform version '5.0' is not compatible with minVersion>=6.0 maxVersion<=6.0. I
-
Ipod cannot be updated. Unknown error (-39)
anyone have any ideas, i cant upload any of my songs or podcasts or photos.
-
Activation problem with Acrobat V7 on Windows Vista
I recently purchased a new computer with Windows Vista Home Edition pre-loaded. I then installed my Acrobat Version 7 software which had been installed and operating trouble-free on my old Windows XP machine. Everything seemed to install OK but then
-
PRIF-33 and CRS-02307 while changing public network interface, RAC
Hi, I'm working on an Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management. It's a 3 nodes RAC: mgvdb01/02/03 After the installation I had to chang
-
PS CS3 images far more red than Camera Raw 4.6
Consistently when opening images in Photoshop CS3 the image as viewed in PS and LR 3.6 is considerably redder than in Camera Raw 4.6 and the Save-for-Web image displayed in Firefox. I principally want my images to be suitable for print media but want