Reader.skip() not work in my code?
I am writing a program to try to let reader to skip a line if some certain condition happened, But skip() seems doesn't work as I assumed.
import java.io.*;
public class WriteHostData {
public static void main(String args[]) throws IOException{
// write to a file
String aString[]={"monkey","fish","dog","happy","horse"};
File file = new File("testFileForWriter");
FileWriter fileWriter = new FileWriter(file);
BufferedWriter writer =new BufferedWriter(fileWriter);
for( int i=0; i<aString.length; i++){
writer.write(aString);
writer.newLine();
writer.close();
// read the file
if( file.exists()){
String value;
FileReader fileReader = new FileReader(file);
BufferedReader bufferedReader= new BufferedReader(fileReader);
value = bufferedReader.readLine();
while( value!=null){
try{
for( int i=0; i<value.length();i++)
if( value.charAt(i)=='d'){
System.out.println(value.charAt(i));
bufferedReader.skip(value.charAt(i));
}catch(StringIndexOutOfBoundsException e){
e.printStackTrace();
System.out.println(value);
value = bufferedReader.readLine();
fileReader.close();
}// end of main
}// end of class
output:
monkey
fish
d
dog
But what the output I want is:
monkey
fish
horse
what is wrong here?
J-Star:
You just caught the point. readLine() could do the job.
public static void main(String args[]) throws IOException{
// read the file
if( file.exists()){
String value;
FileReader fileReader = new FileReader(file);
BufferedReader bufferedReader= new BufferedReader(fileReader);
value = bufferedReader.readLine();
while( value!=null){
if(value.charAt(0)=='!' ){
value = bufferedReader.readLine();
else if( value.charAt(0)=='d'){
value = bufferedReader.readLine();
System.out.println(value);
value = bufferedReader.readLine();
}// end of while loop
fileReader.close();
}// end of main Now it works.
Similar Messages
-
Tun miniport adapters are not working and the camera card reader is not working on a T61P.
The Microsoft tun miniport adapters #4,2, and 3 are not working. They display code 10 error message. Also the USB mass storage device (camera card reader) is not working.
I have tried to uninstall and update the drivers to no avail. I have used ThinkVantage Tool Box. It only lets me know that they are not working. It does say to reinstall them. I have tried. All effort has failed.
All was find until I ran several updates via ThinkVantage.
All suggestions would be appreciated.
Thank you,
TomYou will not lose data if you back up
Worth doing the basic troubleshooting
Reset
Restore best as new since you have issues ,then you will know if it has started to function correctly ,if not .....
Visit Apple store since if it isn't software probably iPhone is on it's way out -
Layout Mode not working in T-Code SQVI for some GUI
Dear Experts,
It has been found that the Layout mode is not working in T-code SQVI in some of our users Systems . The Layout Mode is working perfectly fine in some system though. If we select Layout mode in some system it is showing screens the same as in Basis Mode.
The GUI version is same in both the machines and both are having the same OS.
GUI Version : 710
OS : XP
Kindly suggest if any settings needs to be done in System or GUI so that all the systems get the same interface of Layout Mode as required.
- JiteshHi experts,
Just wished to post the solution of the Issue raised by me...
I just needed to update my GUI Patch level available at market Place.
Thanks.
Jitesh -
CD/DVD reader is not working, please help.
My cd/dvd reader is not working at all, when I put any cd or dvd on it, the led of the reader starts blinkin but then it stops and nothing happens. I'm using a hp pavilion dv7-1025nr, windows vista 64-bit. Maybe there are some drivers that i should download, in that case, can some one help me with link?, Thanks.
When you access this page from the link, ensure that this is your machine by entering your Model # and then trying your Product # (both on the Service Tag on the bottom of your computer). This will confirm your Model#/Product# for future updates.
HP Support & Drivers Page for Your Machine
Sig: Pavilion Model Series# dv9500t (t=Intel)_CTO_Prod# RL653AV_Vista Ultimate (64-bit)_SP1_Intel 2 Duo CPU T7500_2 GB Ram_BIOS F.09_NVIDIA 8600M GS_200GB 7200RPM SATA Dual HD (100GBx2)_HP 300GB HD USB Kit for xb3000_8/2007 -
After upgrading, Adobe reader is not working.
After upgrading to 10.10.2, Adobe reader is not working. It is asking for user agreement to be signed. I cannot find this again. I have uninstalled and re-installed but still does not appear. I have tried to contact Adobe with no luck. Can anyone help please?
Since you are running OS X 10.10.2, you do not have an iMac (PPC) so you have posted in the wrong forum. I have requested the Hosts to move your post to the correct forum where hopefully someone will see it and help you.
-
Adobe reader will not work with games
adobe reader will not work with games
That is correct. Adobe Reader is intended for viewing PDF files, not for playing games. Perhaps you are thinking of Adobe Flash Player?
-
When I click PDF file, the file does not open and installation software for creative suite automatically begin to start. Even after re-installation of creative suite 5.5, only acrobat reader dose not work and the same phenomena occurs.
Did you ever install Acrobat? It is not installed automatically with CS, but requires an extra installation step.
-
I have a hp pavilion dv4-2160us and the dvd/cd reader is not working. it can't detect the disk too. i've done everything on the hp website to fix it (reinstall the driver, etc.), but nothing seems to help. can anybody help me with my problem? thanks!
When you say DVD drive is not working and cant detect disks, Is the Optical drive listed in Device manager and My computer? Is not reading any specific disks or all kinds of disks ?
Also have you tried all possible troubleshooting steps found over here
//Click on Kudos and Accept as Solution if my reply was helpful and answered your question//
I am an HP employee!! -
Satellite C850-B635 and Win7 - card reader is not working
My notebook came with windows 8 and the card reader was working
but I installed windows 7 64-bit , downloaded all required drivers to my notebook , but the card reader is not working now .
I downloaded a driver called card reader controller but it didn't work as well
I don't know if there is a problem or there is a driver that I should install and I don't know .
please help me solving that problem .
In my windows device manager these devices isn't recognized :
*PCI simple communications controller
*SM Bus Controller
*Unknown Device
I tried to search in my drivers download page in Toshiba website but couldn't find these
please help me making my card reader working again.
Regards
Message was edited by: domakingTo me the case is simple and the reason why the SD card reader does not work is that an compatible driver isnt installed.
My theory seems to be correct since the SM bus controller and PCI simple communications controller appear in the device manager and I guess one of these devices belongs to the SD card reader/controller.
I think you should simply install this Realtek Card Reader Controller which I found on the Toshiba EU driver page
http://support1.toshiba-tro.de/tedd-files2/0/carc-20130924161048.zip
Furthermore you should install all other Win 7 drivers as well as Toshiba tools available for Satellite C850 series.
Very important is the chipset driver, USB 3.0 driver (Win 7 needs this driver to control the USB 3.0 port), display driver. etc
Not very essential tools are Bulletin Board, Online Product information, Reeltime, etc such additional tools dont improved the notebook performance so its up to you if you want to use these software parts -
Since I installed lion, my SxS Card reader is not working any more. Some advise?
since I installed lion, my SxS Card reader is not working any more. Some advise?
Try resetting the PRAM https://support.apple.com/kb/HT1379
-
Installed Photoshop Elements. Card Reader still not working.
Installed Photoshop Elements. Card Reader still not Working.
And what does any of that have to do with Adobe software? You better check your hardware setup and install the proper driver for whatever card reader you use...
Mylenium -
HELP!!! My Card reader is not working!
My card reader is not working and this is extremely frustrating when trying to transfer data from one device to my my macbook pro. Is there any one out there that can help me with this issue?
Some people (me included) have found the problme to be a stuck contact inside the socket on the MacBook Pro. The far left contact appears to get stuck in the "inserted" position (depressed) and fails to signal to the computer that a new card has been inserted. This contact is partially hidded behind an alignment key molded into the socket. One fix is to carefully (and I mean carefully) use a toothpick to gently prod the contact into its "not-inserted" position (it will pop up and work afterwards). If you aren't comfortable doing this yourself, you can get an inexpensive card reader that connects via USB as a workaround.
If the computer is still under warranty (or you have AppleCare), take it in and let Apple or an AASP fix it for you. -
SD card reader is not working in my MBP early 2011. Is there any solution?
SD card reader is not working in my MBP early 2011. Is there any solution?
on my macbook iphoto didn't recognise my camera or card reader after upgrading to iphoto '11,
Evenutally I went to an application called Image Capture which I seem to have already. This read the camera contents. I selected the images I wanted and then imported them into iphoto which was one of the options given. It worked. God knows why one has to go through two steps. But I'm feeling pretty triumphant. This may help you if you haven't already sorted it. -
Numeric key pad is not working, card reader is not working
Numeric key pad is not working, card reader is not working,
Did you (or someone else) physically open the laptop case?
If you did, then some cables might have gone loose inside.
If you didn't, for the card reader, check if appropriate device drivers are installed in windows device manager.
for the numeric keypad, first tap once on the NUM LOCK key and check.
If this doesn't solve the problem, boot to "Safe mode", and check. -
Satellite X200 and Windows7 (32bit) - Card Reader is not working
Hi All,
Hope someone can help.
My X200-219 has recently been upgraded to Windows7 and although it is running well, (better than with Vista for now anyway), the card reader is not working.
Do I need a driver installed??
Looked at various but can't find anything obvious??
Cheers and thanks
DBHi
Try please to install THIS driver .
It is Vista 32 bit driver for Digital Media Card Reader. I hope it will work.
Send some feedback.
Maybe you are looking for
-
I have a sharepoint 2013 portal. I have custom documentlibrary with 10 contenttypes. When you upload a new document you can select a contenttype. After selecting the contenttype you see the columns/fields to fill in. One of the fields is a datetime c
-
My cursor has disappeared in Word after updating my iMac.
Just updated to OS X 10.9.3 and now I can't see my cursor when using word how do I fix this?? I'm writing an essay and it's extremely frustrating. Can someone please help me fix it.
-
When I zoom In, My photos look pixelated?
I have just recently been having this problem, never have before... So basically when I zoom in past 100% it goes way more pixelated than it should be. I was looking into " Display performance ", I think that may be the problem but I can't find the w
-
MSS Compensation Management - HRWPC_EVAL_PATH
Hi, In the MSS Compensation Management, I need to achieve the functionality which will allow the manager to view all employees under him/her except the employees which are direct reportees to Him/Her . I am coding in the Function Module HRWPC_EVAL_
-
Not enough RAM? Functions do not run
Mein Computer hat 16GB Arbeitsspeicher Intel(R) Core (TM) i5-4430 CPU 3G.00GHz, 64 Bit Betriebssystem. Wenn ich eine große Datei habe 70 x 80cm 200dpi und große Pinsel benutze kommt die Meldung nicht genügend Ram. In den Voreinstellungen bei Photosho