Hi i want to know how to write a tab to a file
hi,
this is ayesha.
I have a requirement wherein i am writing to the windows\hosts file an ipaddress followed by tab followed by domain name.
ex:
127.0.0.1 localhost
192.133.4.34 ayesha.com
113.24.5.34 basic.com
And the code i have used is:
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("*****************starting of the program");
//System.out.println("irfan"+'\u0009'+"lets see");
//System.out.println("irfan");
try {
File f = new File("C:\\WINDOWS\\system32\\drivers\\etc\\hosts");
RandomAccessFile raf = new RandomAccessFile(f,"rw");
// Read a character
char ch = raf.readChar();
// Seek to end of file
raf.seek(f.length());
// Append to the end
// raf.writeChar('\n');
String toBeSubstituted=System.getProperty("line.separator");
raf.writeBytes(toBeSubstituted+"aString"+"\t"+"end"+"\t"+"end");
// raf.writeBytes("\t"+"end");
raf.writeBytes(toBeSubstituted);
raf.writeBytes(toBeSubstituted);
System.out.println("ending the application*******************************************************");
raf.close();
But my problem is when i write:
raf.writeBytes(toBeSubstituted+"aString"+"\t"+"end"+"\t"+"end");
I get the output on a new line as :
astring end end(ie astring followed by space followed by tab followed by end)
But i want to write "astring" followed by tab followed by end..................
Can anyone help me in this????????????????????
And why it is printing the space instead of tab the first time and a tab the second time.
Regards,
Ayesha.
Okay, first, why are you using RandomAccessFile and writing bytes? Use a FileWriter, probably with a PrintWriter wrapped around, and just send Strings.
pw.println(ipAddress + "\t" + hostName);
Similar Messages
-
I want to know how to "bookmark all tabs" in FF 4 as I used it extensively in FF3
I have had problems with FF going back to the "restore" option. However it always went back to an old restore not the last set of tabs that I was in.
As a workaround I would end each session by "bookmark all tabs" and then when I restarted just "open all in tabs"
However I cannot find any way to do this in FF4, can anyone help me?Right-click a tab to see that menu item or use '''{Ctrl + Shft + D}''' to bookmark all tabs.
Firefox 4.0 automatically saves the previous session, and the '''about:home''' Homepage has a hyperlink for '''Restore Previous Session''' or you can do that thru History. Seems to work better than it did in 3.6. -
Hey!
I just graduate from high school.. im gonna study Computer Enginnering. Im working for my family and they need an app that works like iBook. We have the eBooks and then they want me to do an app where they can sell the eBooks and read them. I have Xcode, but I dont know how to write codes or where to begin in all of this. I want to make the app first for iPad but if it can be for both iPad and iPhone better. I just want recommendation and help. Please and Thanks!!hello i hope your having a good day but can you reply to me if you got the codes to make an app because i want to make an app too thanks
-
Want to know how to check for new line character in text file
Hi All,
I`m trying to read data from text file. However I`m not sure whether the data is in 1st line or nth line. Now I`m trying to read the text from the readline. But if text is "" and not NULL then my code fails. So I want to know how to check for new line character and go to next line to find the data. Please help.
Thanks
static int readandwriteFile(Logger logger,String filepath){
BufferedWriter out = null;
BufferedReader in = null;
File fr = null;
int get_count = 0;
try {
if(new File(filepath).exists())
fr= new File(filepath);
System.out.println("FileName: "+fr);
if(fr != null){
in = new BufferedReader(new FileReader(fr));
String text = in.readLine();
if(text != null){
get_count = Integer.parseInt(text);
in.close();
else{
get_count = 0;
else{
out = new BufferedWriter(new FileWriter(filepath));
out.write("0");
out.close();
} //Reading of the row count file ended.
catch(Exception e) {
e.printStackTrace();
finally {
try{ if (in != null) {
in.close();
if (out != null) {
out.close();
catch(Exception e) {
e.printStackTrace();
return get_count;
}You are calling the readline() only once which means you are reading only the first line from the file...
Use a loop (Do-While preferably)
do{
//your code
}while(text == "") -
I use iPhoto and want to know how to get the 'key photo' i select on my McBook Pro to be the same one that gets used on my iPhone 5s when i sync. i also want the events to appear on the iPhone in the same order i have them on my macbook. any ideas there too?
Killerfinch wrote:
My new yahoo account nestles comfortably in iCloud on the mine iPad.
No, your Yahoo account is not in iCloud (which only handles iCloud mail), it is in Yahoo, and the Yahoo mail account is on your iPad.
But the MacBook Pro will have none of it! I write this question now as I fear that I will be totally demented very soon and unable to formulate my thoughts clearly!
Get the correct settings for your account from Yahoo and set it up manually.
By the way, I also find the "password" issue problematical. It seems Apple want my Apple password rather than my eMail password. All very confusing.
That would depend on what you are trying to do. -
I am a teacher of mathematics and i have a windows pc, but i want to do the next step. I want to buy an iMac. I want to learn how to write mathematical equations and how to do geometrical schema in my documents with iMac. Help me please!!! Thank you very much!!!
Bonjour VAGRAI
1) To write math expressions in a text :
— Microsoft Office 2011 etc. for Mac use its included Equation Editor.
— OpenOffice.org (OOo) and NeoOffice : download free Dmath 3.3.
— iWork (Pages, Numbers, Keynote), download free MathType 6.7, fully functional for 30 days, then becomes « Lite » for life as good as the Microsoft equation editor ; it’s better than using Grapher’s equation editor (Applications > Utilities) because MathType can be called from Pages and allows editing equations by clicking the math expressions your text (details on MathType website) .
— Graph.app 2.3 in Mountain Lion is built to draw curves and surfaces from equations, so it uses an equation editor less powerful than mathType, but it’s easier typing expressions. You may get 2D 3D geometrical drawings from clever equations. Suggest a glance at http://y.barois.free.fr/grapher/ to know all about Grapher (83 pages Instructions for Use - Grapher) and some examples
2) Geometrical schema :
— GeoGebra is very popular and used by math teachers.
— Google SketchUp 8 was not built for mathematics but for architecture, but it’s very easy using it to draw 2D 3D surfaces and solid figures.
— ShapeOnYou.app allows simples geometrical figures http://pierre.chachatelier.fr/programmation/shapeonyou_en.php
3) Some useful websites for screen shots of geometrical schema :
http://www.mathcurve.com/
http://perso.orange.fr/roger.assouly/
Drawings files PDF, TIFF, JPG … can be inserted in an iWork window (Pages).
I hate LaTex : not necessary to write math books !
Au revoir VAGRAI,
YB24
Attachment : lines and curves were made with Google SketchUp 8, screen copied (Command-Shift-4), inserted on a Pages sheet to add letters figures rectangles title.
SketchUp allows drawing precisely an arc of circle 325 mm radius 22,5° angle for instance. -
I want to know how I can have the contact to office
I want to know how I can have the contact to the office where I can write a complain because I have a 8 years old daughter there have bought for a lot off money. I call a office here in Denmark Friday, and the woman promises me to send me the e-mail add, but still I dont received it, so I hope by this way I can have the e-mail adrress.
Best regards
Sara Sloth Frederiksen
<Email Edited by Host>http://www.apple.com/dk/support/itunes/
-
Dear masters in labview :I want to know how to add to XO game in labview a feature where a single player plays against any programed program and never wins.
Free Kudos for anyone who is able to solve this problem.
Thank you for your time.
Best regards,
Jupiter
extinct when hell froze overjcarmody wrote:
I'd also like to join in the OP's offer of free kudos to anyone that can write a tic-tac-toe game that can consistently beat me.
Now that's suddenly an entirely different requirement!
"user never wins" != "program can beat user"
Since the perfect game is a draw, "user never wins" is actually possible, but it can never beat a perfect player.
LabVIEW Champion . Do more with less code and in less time . -
I wanted to know how to unlock my iphone, since I had to restore it and when it restarted, it appeared this message: "The SIM card que you currently have installed in this iphone is from a carrier that is not supported under the Currently actuvation policy that is assigned by the server activion. this is not a hardware issue with the iPhone. Please insert another SIM card from a supported carrier or request que this iphone be unlocked by your carrier. Please contact Apple for more information. "
I need help, I use my phone for everything enclusive to work. I appreciate if you can help. I'm from Brazil. My name and giullia.Did you purchase this device from Apple or an authorized reseller? It sounds as if you had a device that was jailbroken/hacked to operate on your carrier. Upon updating the iOS, it is now locked back to the original carrier the device was locked to.
Only the carrier the device is locked to can authorize an unlock. You will need to make contact with that carrier and see if they provide unlocking services, and if they do, if you qualify for an unlock. Otherwise, you are out of luck. One that carrier can take care of the unlocking. -
I am going to buy a Mac desktop and want to know how to transfer all my purchases and uploaded music from my PC. I originally started using iTunes on my PC so it has everything I have ever purchased or uploaded from my own collection of music.
How can I do this to ensure all videos and music transfer over and not just purchases? Do they do it at the Apple Store or at Best Buy? help!Move iTunes Library from PC to MAC
http://www.macworld.com/article/146958/2010/03/move_itunes_windows_mac.html
Also, See here if you need to... iTunes to an External Drive
http://support.apple.com/kb/HT1751 -
I want to know how to take music out of other folders in my iTunes...
I can't take music from other folders on my iTunes and put them on my iPod. I want to know how I can do this, because I feel like I have tried everything but I may not have tried everything. Can someone tell me how I can go about doing this; taking music from another folder and or file from my iTunes and put them onto my iPod.
Your post is somewhat confusing. If all of your music is in your iTunes music folder, it should sync to your iPod. If you have music on your system's HD that is not in iTunes, you will need to use the "add file or folder" function in iTunes to bring these other files into the iTunes music folder.
-
I have three email accounts and want to know how to change the display order.
I have three email accounts and want to know how to change the display order.
Install this add on.
https://addons.mozilla.org/en-US/thunderbird/addon/manually-sort-folders/?src=search -
I have an airport express and want to know how to set up two different wireless networks. One with 5GHZ and one with 2.4GHZ so different devices can connect to either. I have an iphone 4 that will not connect to 5ghz.
thank you!Your AirPort Express is already providing two separate 2.4 GHz and 5 GHz bands, but each band is using the same wireless network name.
This is the default setup for the AirPort Express, which is recommended for most users. The theory here is that devices will automatically connect to the best quality signal based on their capabilities and distance in relation to the AirPort Express.
It is possible to assign a different name to the 5 GHz band, and then "point" devices at that network to connect. Some users swear by this option.....(I am not one of them).... but you might want to give it a try to see how it works for you.
Open Macintosh HD > Applications > Utilities > AirPort Utility
Click on the AirPort Express
Click Edit in the smaller window that appears
Click the Wireless tab at the top of the next window
Click Wireless Options near the bottom of the next window
Enter a check mark next to 5 GHz Name.....which will automatically add "5 GHz" to the network name....so you can identify it
Click Save, then click Update and wait a full minute for the Express to restart
Now you will need to "point" your 5 GHz capable devices at the 5 GHz network name. 2.4 GHz devices will connect to your "other" network name. -
I have an ipad 2 and I noticed I have over 3000 emails in All Mail. I want to know how can I delete these emails. It looks like you can only do it one at a time. It will take me forever. Please help me.
You can only delete them one at a time on the iPad. If you have an IMAP email account, go to your email in on the server using a web browser and select as many as you can at a time and delete them that way. That action will be reflected on the iPad. In IMAP - whatever you do on one device syncs across all devices. If you have POP email - start deleting one at a time.
-
In My iphone 5s,i have disabled automatic download from whatsapp app.So whichever images,video i feel is good i download them and then save them to my camera roll section.So i want to know how can i remove the images from cache of my phone which are downloaded and not saved,but they remain in cache.
Even in some apps i have data which i want to remove,but cant find a way to remove them and they are in my cache eating up my memory.Try assigning Queen as the Album Artist on the compilations in iTunes on your computer.
Maybe you are looking for
-
I am able to access the websites they need within my user account, but that is not where I want them doing their homework!
-
JTable and TableModelEvent: tableChanged(TableModelEvent) called twice
Hi, This question has already been posted (http://forum.java.sun.com/thread.jsp?forum=257&thread=114517) but wasn't answered at that time so i decided to make another attempt. How comes that tableChanged(TableModelEvent) is executed twice for each ch
-
IMove 2013 Doesn't Open Library
I couldn't get iMoie 2013 to quit so I did a force quit. Now I can't get it to open my 600+GB library. Console shows these message: 3/29/14 1:25:31.761 PM WindowServer[100]: disable_update_timeout: UI updates were forcibly disabled by application "i
-
Custom retention period.
Hi Experts, Is there any table which contains the archiving object names and their corresponding retention periods. The tables like CRMC_ORDER_ARC, BBPV_ARCH_RESI, PLMV_AUD_OBJARCH are there but those tables contain resident time values for order ty
-
Fatal Exception occurred when trying to execute a JAR file
Hi, I have compiled my project in a jar file with the purpose of having an 'almost' executable file that would run with a simple double click. When running this file from the netbeans directory, it works fine, but if I move this jar file to, say, my