How to delete the beginning of a file?
Hi,
is there a way to delete the beginning of a file, or do I have to copy the rest of the file and create a new one and then delete the old one?
Lets say my file contains "ThisIsMyFile" and I want to delete "This", so that my new file contains "IsMyFile", how can I do this?
thanx
You have to copy.
Similar Messages
-
How to delete the specified line in file?
How to delete the specified line in file? In case of deleting a specified line in a file, how to do?
Line 1
Line 2
Line 3
Line 4
Line 5
The case is a file including the above content. Now I wanna to delete the "Line 3" and how to realize the action in Java?An alternative solution can be :
import java.io.LineNumberReader;
import java.io.IOException;
import java.io.File;
import java.io.FileReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.PrintWriter;
public class LineDeleter {
public static void main(String args[]){
try {
//suppose you want to delete line 3
int lineToBeDeleted = 3;
File f = new File("line.txt");
long fileSize = f.length();
//Wrap the FileReader with a LineNumberReader. It will help you
//identify the lines.
LineNumberReader lnr = new LineNumberReader( new FileReader(f));
//Wrap the FileWriter object with BufferedWriter object. Create it with the buffersize
//equal to the file size.
BufferedWriter bw = new BufferedWriter(new FileWriter(new File("line1.txt")),(int)fileSize);
//Wrap BufferedWriter object with PrintWriter so that it allows you
//to print line by line
PrintWriter pw = new PrintWriter(bw);
String s=null;
while ( (s=lnr.readLine())!=null ){
System.out.println(s);
int lineNumber = lnr.getLineNumber();
//match the line number
if(! (lineNumber==lineToBeDeleted)){
pw.println(s);
pw.flush();
lnr.close();
pw.close();
catch(Exception e){System.out.println(e);}
If you want you can rename the line1.txt to the original file name.
I hope this helps.Good luck!!!!!! -
i accidentally deleted or removed the line that has file, history, etc. And i was wondering how to replace it. ive gone to firefox properties and even ugraded to the newest version but it didnt bring the tabs back. how do i recover them?
That's the Menu Bar, and users can hide it in Firefox versions 3.6+
'''<u>Menu Bar</u>''' (File, Edit, View, History, Bookmarks, Tools, Help)<br /> Firefox 3.6.x versions allow the user to hide the Menu Bar.<br />
*Tap the ALT key or the F10 key, Menu Bar will display, click View, click Toolbars, click Menu Bar to place a check mark next to it, '''''OR'''''
*Press and hold the ALT key while pressing the letters VTM on your keyboard, then release the ALT key
*See: http://support.mozilla.com/en-US/kb/Menu+bar+is+missing
'''<u>Other Toolbars</u>''', see: https://support.mozilla.com/en-US/kb/Back+and+forward+or+other+toolbar+items+are+missing<br />
'''<u>Status Bar</u>''': click View, click Status Bar to place a check mark<br />
'''<u>Full Screen Mode</u>''': If you have no Toolbars or Tab Bar: Press F11 (F11 is an on/off toggle). See: http://kb.mozillazine.org/Netbooks#Full_screen<br />
Also see: http://kb.mozillazine.org/Toolbar_customization_-_Firefox#Restoring_missing_menu_or_other_toolbars
<br />
The information submitted with your question indicates that you have out of date plugins with known security and stability issues that should be updated. To see the plugins submitted with your question, click "More system details..." to the right of your original question post. You can also see your plugins from the Firefox menu, Tools > Add-ons > Plugins.
*Adobe Shockwave for Director Netscape plug-in, version 11.5
*Adobe PDF Plug-In For Firefox and Netscape "9.3.3"
*Shockwave Flash 10.1 r82
*Next Generation Java Plug-in 1.6.0_15 for Mozilla browsers
#'''Check your plugin versions''': http://www.mozilla.com/en-US/plugincheck/
#*'''Note: plugin check page does not have information on all plugin versions'''
#'''Update Shockwave for Director'''
#*NOTE: this is not the same as Shockwave Flash; this installs the Shockwave Player.
#*Use Firefox to download and SAVE the installer to your hard drive from the link in the article below (Desktop is a good place so you can find it).
#*When the download is complete, exit Firefox (File > Exit)
#*locate and double-click in the installer you just downloaded, let the install complete.
#*Restart Firefox and check your plugins again.
#*'''<u>Download link and more information</u>''': http://support.mozilla.com/en-US/kb/Using+the+Shockwave+plugin+with+Firefox
#'''Update Adobe Reader (PDF plugin):'''
#*From within your existing Adobe Reader ('''<u>if you have it already installed</u>'''):
#**Open the Adobe Reader program from your Programs list
#**Click Help > Check for Updates
#**Follow the prompts for updating
#**If this method works for you, skip the "Download complete installer" section below and proceed to "After the installation" below
#*Download complete installer ('''if you do <u>NOT</u> have Adobe Reader installed'''):
#**Use the links below to avoid getting the troublesome "getplus" Adobe Download Manager and other "extras" you may not want
#**Use Firefox to download and SAVE the installer to your hard drive from the appropriate link below
#**Click "Save to File"; save to your Desktop (so you can find it)
#**After download completes, close Firefox
#**Click the installer you just downloaded and allow the install to continue
#***Note: Vista and Win7 users may need to right-click the installer and choose "Run as Administrator"
#**'''<u>Download link</u>''': ftp://ftp.adobe.com/pub/adobe/reader/
#***Choose your OS
#***Choose the latest #.x version (example 9.x, for version 9)
#***Choose the highest number version listed
#****NOTE: 10.x is the new Adobe Reader X (Windows and Mac only as of this posting)
#***Choose your language
#***Download the file, SAVE it to your hard drive, when complete, close Firefox, click on the installer you just downloaded and let it install.
#***Windows: choose the .exe file; Mac: choose the .dmg file
#*Using either of the links below will force you to install the "getPlus" Adobe Download Manager. Also be sure to uncheck the McAfee Scanner if you do not want the link forcibly installed on your desktop
#**''<u>Also see Download link</u>''': http://get.adobe.com/reader/otherversions/
#**Also see: https://support.mozilla.com/en-US/kb/Using+the+Adobe+Reader+plugin+with+Firefox (do not use the link on this page for downloading; you may get the troublesome "getplus" Adobe Download Manager (Adobe DLM) and other "extras")
#*After the installation, start Firefox and check your version again.
#'''Update the [[Managing the Flash plugin|Flash]] plugin''' to the latest version.
#*Download and SAVE to your Desktop so you can find the installer later
#*If you do not have the current version, click on the "Player Download Center" link on the "'''Download and information'''" or "'''Download Manual installers'''" below
#*After download is complete, exit Firefox
#*Click on the installer you just downloaded and install
#**Windows 7 and Vista: may need to right-click the installer and choose "Run as Administrator"
#*Start Firefox and check your version again or test the installation by going back to the download link below
#*'''Download and information''': http://www.adobe.com/software/flash/about/
#**Use Firefox to go to the above site to update the Firefox plugin (will also install plugin for most other browsers; except IE)
#**Use IE to go to the above site to update the IE ActiveX
#*'''Download Manual installers'''.
#**http://kb2.adobe.com/cps/191/tn_19166.html#main_ManualInstaller
#**Note separate links for:
#***Plugin for Firefox and most other browsers
#***ActiveX for IE
#'''Update the [[Java]] plugin''' to the latest version.
#*Download site: http://www.oracle.com/technetwork/java/javase/downloads/index.html (Java Platform: Download JRE)
#*Also see "Manual Update" in this article to update from the Java Control Panel in Windows Control Panel: http://support.mozilla.com/en-US/kb/Using+the+Java+plugin+with+Firefox#Updates
#* Removing old versions (if needed): http://www.java.com/en/download/faq/remove_olderversions.xml
#* Remove multiple Java Console extensions (if needed): http://kb.mozillazine.org
#*Java Test: http://www.java.com/en/download/help/testvm.xml -
How to delete the standby archive log files in ASM?
Hi Experts
we have a realtime downstream replication that is using the a location in ASM to put the shipped logs files.
set up by
ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='LOCATION=+BOBOASM/NANPUT/standbyarchs/
VALID_FOR=(STANDBY_LOGFILE,PRIMARY_ROLE)' Scope=BOTH;
What shall i do to clean up those files ?
Any procedure or script to do that?
ThanksHello Haggylein
check this out, seems to work
--- redologs used or not?
---- when purgeable we can delete it
COLUMN CONSUMER_NAME HEADING 'Capture|Process|Name' FORMAT A15
COLUMN NAME HEADING 'Archived Redo Log|File Name' FORMAT A25
COLUMN FIRST_SCN HEADING 'First SCN' FORMAT 99999999999
COLUMN NEXT_SCN HEADING 'Next SCN' FORMAT 99999999999
COLUMN PURGEABLE HEADING 'Purgeable?' FORMAT A10
SELECT r.CONSUMER_NAME,
r.NAME,
r.FIRST_SCN,
r.NEXT_SCN,
r.PURGEABLE
FROM DBA_REGISTERED_ARCHIVED_LOG r, DBA_CAPTURE c
WHERE r.CONSUMER_NAME = c.CAPTURE_NAME and PURGEABLE = 'YES';
-- Now the script
-- to be executed on the downstream database
-- generate the list of logs to be purged and executed in a ksh script
-- sqlplus "/as sysdba" @$HOME/bin/generate_list.sql
SET NEWPAGE 0
SET SPACE 0
SET LINESIZE 150
SET PAGESIZE 0
SET TERMOUT OFF
SET ECHO OFF
SET FEEDBACK OFF
SET HEADING OFF
SET MARKUP HTML OFF SPOOL OFF
spool list_purgeable_arch_redologs.ksh
SELECT 'asmcmd ls ' || r.NAME
FROM DBA_REGISTERED_ARCHIVED_LOG r, DBA_CAPTURE c
WHERE r.CONSUMER_NAME = c.CAPTURE_NAME and PURGEABLE = 'YES';
spool off
exit
# eventually we can call it from a script
# !ksh
# delete of the shipped redologs
# to be performed on node 2
# not to be used on
$HOME/bin/export ORACLE_SID=+ASM2
./list_purgeable_arch_redologs.ksh
exit -
How to delete the record in the file present in the application server?
Hi,
I have two questions.
i) How can I delete a record based on some condition in the recordx in the file that is present in the application server?
ii) How can I lock the users whiel one user is accessing the file on the application server?
Thanks in advance.
SuvanHi,
If u want a frequent deletion this approach to delete a record from a file will havee unnecesary copy of records from one file to another and deletion of one file and renaming activities.
Instead what u can do is Add and field del_flag to ur record structure.
If u want to delete the record from a file just mark this del_flag as 'X'.
While processing u can have a loop like
loop at it_XXX where del_flag <> 'X'.
endloop.
This will logically delete the record.
When u r to finish the application at that time only perform this copying / deleting / and renaing activity
Hope this helps.
Cheers,
Nitin -
How to delete the file with space in name
Hi
I want to delete the file "test ex.txt" file.
i run the following command in command prompt.i can delete the file successfully.
/bin/rm -f /mnt/"test ex.txt"
I want to run the command from java.So i am using the following code
String cmd = "/bin/rm -f /mnt/\"test ex.txt\"";
Runtime rt = Runtime.getRuntime();
process = rt.exec(cmd);
The file was not deleted.
How to delete the file with space in name?
Help meUse the form of exec that takes an array of command + args.
arr[0] = "/bin/rm"
arr[1] = "-f"
arr[2] = "/home/me/some directory with spaces";Or use ProcessBuilder, which is the preferred replacement for Runtime.exec, and which Runtime.exec calls. -
HOW to delete the saved score in a game downloaded from the app store to restart the game from the begining with fresh scores.
i am unable to do so. please helpIn system preferences, create a new account again, using the short name of the "deleted" account. You may be prompted to re-use the old home folder. Log out and log in to test it worked. Then log in as your new admin, and do the delete process again. Don't choose to securely delete this time - just a regular delete.
When you have time to spare, go to Disk Utility, and use the Erase tab to securely erase free space on the drive. This will accomplish the same thing that your originally tried to do. Use the fastest method - anything more secure is a waste of time. You may need to run it overnight - it can take several hours.
Matt -
How to delete the temporary files when we log out from ESS
Hello expert,
In my company we are running ESS using ITS server, do you know how to delete the temporary files when we log out from ESS?
Thanks.The temporary files used by ESS. For example paystub pdf file.
-
got a new wireless connection for my mac and cannot figure out how to delete the last connection service I had. Everytime I shut the computer, the network goes back to the other one. I cannot find the file ANYWHERE
Under Network Preferences, select the WiFi
click on "Advanced..." button
Select the network you want to delete from the list and click on "-"
Click "Ok"
Click "Apply"
Well done ;-)
You may also want to delete the wireless key from Keychain.
Open Keychain, seach for the old wifi network name, slect it and click delete -
How would I erase the beginning of a file?
I want to be able to erase the beginning of a file, while writing to the end...WITHOUT reading the whole file and writing it again because that would be a waste of resourses. Obviously I know that option is available.
My situation is that I am adding lines to a log file, and I want to remove any entries that are X hours old. Logging a lot of information would mean that every few seconds, an entry is older than X hours and needs to be removed. It doesnt have a set number of lines so I can't just recycle the file by doing something like: if at line number Y, start at line 1 and remember the current line number.
Adding to the top of the file, pushing the others lines down, and making cuts at the end would also work, but the same situation arises, how do I add to the beginning of the file, without having to copy the entire file to add the entry to the top.
The reason I don't want to read the whole file is because having to read the whole file and write the whole file when an entry is made is time consuming and wastes CPU and memory, especially when the logs are coming in several lines a second.I would think it could easily be done. say you want to erase the first 10 bytes, why cant you just say move the start of the file up 10 bytes. Somewhere in the filesystem the start of the file is stored. I found underlying file copying that claims this in FileChannel's transferTo and transferFrom:
This method is potentially much more efficient than a simple loop that reads from this channel and writes to the target channel. Many operating systems can transfer bytes directly from the filesystem cache to the target channel without actually copying them.
If I can't just chop, I'll have to copy quickly at scheduled intervals.
This is code I ran to test the above quote:
public static void main(String[] args) throws Exception{
args = new String[2];
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter File Name:");
args[0] = input.readLine();
System.out.println("Enter test (0-2):");
args[1] = input.readLine();
long time = System.currentTimeMillis();
int version = Integer.parseInt(args[1]);
switch (version) {
case 0:
BufferedReader in = new BufferedReader(new FileReader(args[0]));
PrintWriter out = new PrintWriter(new FileWriter("tempfile.txt"));
in.readLine();//skip line.
for (String line = in.readLine();line != null;line = in.readLine()) {
out.println(line);
in.close();
out.close();
break;
case 1:
RandomAccessFile raf = new RandomAccessFile(args[0],"rw");
String line = raf.readLine();
long offset = raf.getFilePointer();
byte[] b = new byte[1024];
int bytes = 1024;
long index = 0;
System.out.println("index = " + raf.getFilePointer());
System.out.println("index = " + line.length());
while(bytes == 1024) {
bytes = raf.read(b);
index = raf.getFilePointer();
raf.seek(index - bytes - offset);
raf.write(b,0,bytes);
raf.seek(index);
raf.setLength(raf.length()-offset);
raf.close();
break;
case 2:
RandomAccessFile raf2 = new RandomAccessFile(args[0],"rw");
String line2 = raf2.readLine();
long offset2 = raf2.getFilePointer();
FileChannel f = raf2.getChannel();
FileChannel g = f.position(0);
g.transferTo(offset2,raf2.length() - offset2,f);
raf2.setLength(raf2.length()-offset2);
raf2.close();
break;
System.out.println(System.currentTimeMillis() - time);
}and had these results
166MB Log File
Linux Mandrake 900Mhz
Case 0 = 32914 ms
Case 1 (1k byte[]) = 15043 ms
Case 1 (16k byte[]) = 6988 ms
Case 1 (1MB byte[] = 6113 ms
Case 2 = 6188 ms
:-/ guess this proves that the FileChannel can't chop -
Concept:
Every month i need to find the list of .rar files from the
E:/TempBackup directory from the different environments (remote desktop servers) and i need to delete the current month
.rar files alone from the respective (E:/TempBackup) directory. below is example files structure inside the
E:/TempBackup.
example:
zDROP_2014_08_31_Backups.rar
zDROP_2014_09_31_Backups.rar
zDROP_2014_10_31_Backups.rar
from the above list i need to delete the zDROP_2014_08_31_Backups.rar(current month) file alone and also logs should be capture for this deletion.
key words for this are zDROP and Current month and date.
i need a stored procedure for this concept. could you please help on this.Hello,
You can schedule an operating system task (Control Panel -> Schedule task) to either call a batch file or a PowerShell script.
Please read the following resources for examples:
http://social.technet.microsoft.com/Forums/windowsserver/en-US/61373719-fffb-4d94-bdbe-7d8ed8620b44/delete-filesfolders-on-remote-servers-using-powershell?forum=winserverpowershell
http://www.networknet.nl/apps/wp/archives/943
http://jeffwouters.nl/index.php/2011/10/powershell-script-to-delete-files-older-that-a-week/
Hope this helps.
Regards,
Alberto Morillo
SQLCoffee.com -
How to delete the foreign archivelogs in a Logical Standby database
How do I remove the foreign archive logs that are being sent to my logical standby database. I have files in the FRA of ASM going back weeks ago. I thought RMAN would delete them.
I am doing hot backups of the databases to FRA for both databases. Using ASM, FRA, in a Data Guard environment.
I am not backing up anything to tape yet.
The ASM FRA foreign_archivelog directory on the logical standby FRA keeps growing and nothing is get deleted when
I run the following command every day.
delete expired backup;
delete noprompt force obsolete;
Primary database RMAN settings (Not all of them)
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 9 DAYS;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE DB_UNIQUE_NAME 'WMRTPRD' CONNECT IDENTIFIER 'WMRTPRD_CWY';
CONFIGURE DB_UNIQUE_NAME 'WMRTPRD2' CONNECT IDENTIFIER 'WMRTPRD2_CWY';
CONFIGURE DB_UNIQUE_NAME 'WMRTPRD3' CONNECT IDENTIFIER 'WMRTPRD3_DG';
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;
Logical standby database RMAN setting (not all of them)
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 9 DAYS;
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
How do I cleanup/delete the old ASM foreign_archivelog files?OK, the default is TRUE which is what it is now
from DBA_LOGSTDBY_PARAMETERS
LOG_AUTO_DELETE TRUE SYSTEM YES
I am not talking about deleting the Archive logs files for the Logical database that it is creating, but the Standby archive log files being sent to the Logical Database after they have been applied.
They are in the alert log as follows under RFS LogMiner: Registered logfile
RFS[1]: Selected log 4 for thread 1 sequence 159 dbid -86802306 branch 763744382
Thu Jan 12 15:44:57 2012
*RFS LogMiner: Registered logfile [+FRA/wmrtprd2/foreign_archivelog/wmrtprd/2012_01_12/thread_1_seq_158.322.772386297] to LogM*
iner session id [1]
Thu Jan 12 15:44:58 2012
LOGMINER: Alternate logfile found. Transition to mining archived logfile for session 1 thread 1 sequence 158, +FRA/wmrtprd2/
foreign_archivelog/wmrtprd/2012_01_12/thread_1_seq_158.322.772386297
LOGMINER: End mining logfile for session 1 thread 1 sequence 158, +FRA/wmrtprd2/foreign_archivelog/wmrtprd/2012_01_12/threa
d_1_seq_158.322.772386297
LOGMINER: Begin mining logfile for session 1 thread 1 sequence 159, +DG1/wmrtprd2/onlinelog/group_4.284.771760923 -
How to delete the Translations
Hi All,
We have two ways to delete the personalizations
1) Using Funcational Administrator -> Personalization
query the page and manage personalization and delete the personalization.
2) Using script,
begin
jdr_utils.deleteDocument('/oracle/apps/pon/award/completion/webui/customizations/site/0/ponCompleteAward2PG');
end;
How to delete the translations.
One way is again change the Target language text to English and import the .xlf file.
Is there any other way?
With regards,
Kali.
OSSI.Hi Kali
Please check if this link helps out.It gives one method to delete translations.
http://ramaatoracleapps.blogspot.com/2010/03/migrate-oa-framework-personalizations.html
Thanks
AJ -
ADF Desktop Integration : How to delete the table in Excel?
Hi,
I am using Jdev 11.1.1.3.0 and Excel 2007 for Oracle ADF DI, I had created an ADF table using pageDef file in the excel. Now I wanted to delete that table and use a different pageDef file.
I could not find a way to delete that table.
I deleted full row of tables and then I used different pageDef file and created a new adf table. But when I am running this version of excel, I am getting runtime exception and excel is getting corrupted.
My question how to delete the table not corrupting the Excel.
Thanks
PavanPavan,,
Welcome to OTN.
You can delete the table by selecting the top left column (of the table) and then select delete from the ADFdi tab.
Refer the documentation for more info.
http://docs.oracle.com/cd/E17904_01/web.1111/e10139/get_start_dev_tools.htm#ADFDI608
-Arun -
Reg:How to delete the column in table control also from database table.
Hi Experts,
Once again thank u all for giving the responses.
one more doubt is how to delete the columns of table control and also the record shold delete from ztable.
With Regards,
Saroja.P.Hi,
If you want to delete the rows in the table control and simultaneously delete it from the database table, then you can implement a 'DELETE' functionality specific to your table control. Have a MARK field (you will find that in the screen attributes of the table control -> give a name for the MARK field, you will find an additional MARK column at the beginning of your table control). You can check whatever rows you want to delete from the table control, call the delete module.
"This portion of code inside the LOOP...ENDLOOP.
IF sy-ucomm eq 'F_DELETE'.
gt_itab2-check = mark. " Store the MARK field status into your internal table's correspoding field 'check'
MODIFY gt_itab INDEX tabcontrol-current_line.
ENDIF.
iF sy-ucomm eq 'DELETE1'.
DELETE gt_itab WHERE check eq 'X'. "Your internal table does not have rows that you want to delete
ENDIF.
Now you can modify your database table using the MODIFY statement.
MODIFY ZDB FROM TABLE gt_itab.
Maybe you are looking for
-
Trying to install iTunes for the first time on a Windows 7 64-bit system.
Nothing is working, I have tried including all kinds of forums, sercurity permissions fixes, windows knowledge base, apple knowledge base, even called HP and nothing works. Any help is greatly appreciated. Been at it for three hours already. Thanks i
-
Illustrator CC - Path Length Stats
Does anyone know if there is an alternative to the Path Length and Path Area plug-ins for Adobe Illustrator from Telegraphics? I used these plug-ins in older versions of Illustrator. They're extremely useful in sign design. I could get statistics lik
-
Hi ALL I have two databases A and B. I am working in database A but want to fetch some record from a table which is in database B. I am using a select query like select max(end_dt) from log This log table is in Database B Please give any suggestion.
-
Can't get Wireless Printer to work on Leopard
My wife bought an HP C4580 Wireless Printer the other day and within minutes I got it working on all the computers, Windows and Mac, in the house BUT, I have now installed Leopard on my MacBook Pro and then installed the Drivers for the Printer and n
-
We have the following scenario: Have an enterprise database whit MSSQLServer2000 ready to start to work in the final customer enterprise. Now we have to restore that database in the customer MSSQLServer, which runs on 2005 version. Do you know if we