During file read it is cutting first character of first line
This program has a file 7918.txt
with contents
user=ry;checkout=yes;checkin=yes
user=dg;checkout=yes;checkin=yes
user=nik;checkout=yes;checkin=yes
user=dg;checkout=yes;checkin=yes
when i am trying to read it is displaying (or storing it to another file) after cutting first letter of first line.
ser=ry;checkout=yes;checkin=yes
user=dg;checkout=yes;checkin=yes
user=nik;checkout=yes;checkin=yes
user=dg;checkout=yes;checkin=yes
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class txtSearch2 extends HttpServlet {
// PrintWriter out =null;
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
PrintWriter out = res.getWriter();
String user="nik";
String filename="7918";
try{
BufferedReader br =null;
File tt = new File("myserver/servletclasses/"+filename+".txt");
int ind=0;
int lno=0;
int i=0;
if( tt.exists() ){
br = new BufferedReader(new FileReader("myserver/servletclasses/"+filename+".txt"));
String s, s2 = new String();
while(br.read()!=-1)
while((s = br.readLine())!=null)
out.println("S_______ "+s);
s2 += s + "\n";
out.println("S222_______ "+s2);
if (s.indexOf(user) > -1)
{ out.println("LINE NO "+lno);
ind=lno;
out.println("INDEX "+ind);
lno++;
BufferedWriter bw
= new BufferedWriter(
new OutputStreamWriter(new
FileOutputStream("myserver/servletclasses/"+filename+"x.txt")));
bw.write(s2);
out.println("SSSSSSSSSSSSSSSS@@@@@@@@@@@@@@@@@@222222"+s2);
bw.flush();
br.close();
bw.close();
out.println(" INDNO "+ind);
out.println("LINE NO3///////////////////////// "+lno);
}catch(FileNotFoundException f)
catch(IOException io)
Thanks
Look carefully at your code:
while(br.read()!=-1)
while((s = br.readLine())!=null)See where you chop off the first character?
Similar Messages
-
File Sender adapter not reading the first line
Hi,
I have a scenario configured from file to jdbc adapter.
However, I found a problem in my file sender adapter. My file adpater always not picking up the first line from my text even I have set the 'Document Offset' to 0.
Any Ideas? Thanks.
Regards,
PuaHi Latika Sethi,
My complete input text file is as below, it contains only 2 testing records:-
H1|DIZ1 |A0016507 |10000020|09/2007
H2|ABC0001
D|P|0001|Gaji Pokok | 1,000.09
D|D|0002|Denda | 1,000.00
D|P|0003|Elaun | 1,000.00
H1|PUA1 |A0016508 |10000021|09/2007
H2|ABC0002
D|P|0001|Gaji Pokok | 2,744.09
D|D|0002|Denda | 2,000.00
D|P|0003|Elaun | 2,000.00
After the message mapping, I found the pipeline existed in sxmb_moni as below:-
<?xml version="1.0" encoding="utf-8"?>
<ns:mt_rmp03B_filejdbc_sender xmlns:ns="urn:rmp03:pdrm:ips:jdbcjdbc">
<PaySlip>
..<Header2>
.... <IC>ABC0001</IC>
.. </Header2>
.. <Details>
.... <Jenis>P</Jenis>
.... <No>0001</No>
.... <Deskripsi>Gaji Pokok</Deskripsi>
.... <Jumlah>1,000.09</Jumlah>
.. </Details>
</PaySlip>
<PaySlip>
.. <Header1>
.... <Nama>PUA1</Nama>
.... <KWSP>A0016508</KWSP>
.... <NoGaji>10000021</NoGaji>
.... <Bulan>09/2007</Bulan>
.. </Header1>
.. <Header2>
.... <IC>ABC0002</IC>
.. </Header2>
.. <Details>
.... <Jenis>P</Jenis>
.... <No>0001</No>
.... <Deskripsi>Gaji Pokok</Deskripsi>
.... <Jumlah>2,744.09</Jumlah>
.. </Details>
</Payslip>
There are 2 payslips as for the top payslip node...Header1 tag is missing. It means that during the file sender step....the first line of my record which is :-
"H1|DIZ1 |A0016507 |10000020|09/2007"
is not read into the xi pipeline. Basically this is the problem i faced.
Has somebody facing the same problem before? Currently I have no choice but moved the First line of the text into Second line and left the first line of the text become null/ empty line. As such both records can be successfully read by the XI.
However what I wondered is sometimes clients will do insert the records into the first line and this might made some data loss.
Thanks... -
When I convert my file to excel it cuts off the first two columns, is there a way to fix that??
Hey Diann,
Please let me know whether you are using Adobe Reader or signed up at "https://cloud.acrobat.com/"
If you are using Adobe Reader, then try converting the file online and vice-versa.
Let me know.
Regards,
Anubha -
Arraylist only reading first line of file
I am reading a text file using an arraylist. my file has a single value on each line e.g.
2
3
4
5
however this method is only reading only the first line of each file. is it because of this statement:
String s1[] = number.split("\\s");
I would like to change the method so its not expecting numbers in a single line.. but reads each line and adds it to the collection... how can I do that?
here is getData method that gets the file and processes it.
public static List<Integer> getData(String Filename) {
List<Integer> array1 = null;
// BufferedReader for file reverse.txt
try {
array1 = new ArrayList<Integer>();
BufferedReader bf = new BufferedReader(new FileReader(Filename));
String number = bf.readLine();
String s1[] = number.split("\\s");
for (int i = 0; i < s1.length; i++)
array1.add(Integer.parseInt(s1));
} catch (Exception e) {
e.printStackTrace();
return array1;Faissal wrote:
while(bf .ready()){
readline() will return null if the end of the stream has been reached. ([http://java.sun.com/javase/6/docs/api/java/io/BufferedReader.html]). This condition can be used to determine when to stop reading thereby ensuring that all lines have been read.
EDIT:
Here's a code snippet from [Java Developers Almanac|http://www.exampledepot.com/egs/java.io/ReadLinesFromFile.html]: notice how they close() the stream when they're finished with it. -
"read from measurement file" reads only first line of data
Hello,
I have a problem when trying to read a .lvm file through "Read from Measurements file" with the following block diagram
Problem: it reads only the first line of data from what I can see in the probe window,.
A part of the lvm file for reference.
I haven't used Labview in a long long time, I'm trying to figure out what I am doing wrong.
ThanksSorry meant to attach the lvm. Here it is. (Actually I had to put it in .txt because the forum wont let me upload a lvm file)
I unfortunately cannot share the full vi that record the data as I am not its owner/creator. I'll try to give as much info as I can with the relevant pictures attached, I hope it allows us to at least have an hint of where the problem might be.
(this is in a while loop)
In the stacked sequence, the other pannels are similar to the one shown here: value read fron a variable, converted to dynamic and a signal attribute is set. The "start recording" control operation is "switch when pressed".
Here are the properties of the set signal attributes
And here are the properties of the "write to measurement file"
Attachments:
NoTarget_full circle__Rx_-10-SAMPLE.txt 60 KB -
i have about 5.6 gb or more non purchased medical books as pdf files.i have just bought extra icloud space to transfer to icloud from my iphone and according to their ad i would be avalaible to read them in my first generation ipad but no action?
sorry cancelling while transferring my question some words gone my question is: they say you are able to read and see what you upload into icloud in one time but i uploaded my non purcahesed pdf files on my iphone 4s with latest itunes version and have latest ibooks version but i can not read my pdf files on my ipad in real time and all settings are made as they said. if not available i will cancel my extra icloud storage why pay more if i have to transfer them separetly
-
Trailing spaces problem during file content conversion
I have developed a proxy to file scenario.And am using file content conversion for creating the file. The file is to be a fixed length file.
File Structure
<Header>
<Item>
<Item Trailer>
<File Trailer>
Each tab in the file has the last character mapped to spaces.
Eg: Header00000001 2006011700000000020060<blank space>
Item00000001 2006011700000000020060<blank space>
The problem is that during file content conversion. XI does not preserve trailing spaces at the end of the line i.e.if a particular line in the file ends with space. It terminates the line at the last non-space character (in this case at 060).
However we are required to maintain these trailing spaces at the end of each line.
I have tried preserve white space in data type that does not work.
I know that xslt mapping may solve the problem but I am looking for a workaround with my current graphical mapping.
Looking for suggestions !!
Thanks,
RashidaHi,
I have the problem quite opposite to this where we are getting the trailing spaces at end of each record which should not come.
File structure is
<Record>
- <Data>
<Content>11/09/2007@210@ZACSL007@GBB-56436@PS01@29@1044@19@646@0</Content>
</Data>
</Record>
............. n records
<Header>
<File_Name>UK01</File_Name>
</Header>
Record structure in communication channel used is
Header, Data
Data.fieldFixedLengths 1024
Data.addHeaderLine 0
Header.addHeaderLine 0
Header.fieldFixedLengths 0
Header.fixedLengthTooShortHandling Cut
Data.fixedLengthTooShortHandling Cut
Header.endSeparator '0'
Actually if the length of record is less than 1024, rest of the length is being filled with spaces which should not occur.
Many advanced thanks.
Jitender -
CAN AN EXCEL XLSM FILE READ FROM A CSV AND WRITE BACK TO THE SAME XLSM -VBA
Hey Carlos- Here's the repost.
Could an XLSM file read a line from a CSV file in "A1" and depending on what was in the first column in the XLSM, search the CSV file and find the indexed item in the second column or third? I've done it before with standard VLookup functions and it was cumbersome and very slow, and for some reason, everytime I would save the file it would take forever although the xls file was a single sheet.
i've attacthed a sketch of what I'm talking about, because it's hard to explain and I think the sketch explains it better. Here it is, sorry if it is blurry, it looked fine before I posted:ok, use this version, I changed it a bit. To accommodate the issue with the single cell, I moved the main procedures to a function for a more efficient use.
Sub xlsmCsvLookup()
'have both your xlsm and your csv files open
'in the xlsm file, select a range of cells to look up
'run the script to search all selected cells and get the values from the csv file
Dim csvDataRange As Range 'csv file data column
Dim selRange As Range 'to hold selected cells
Dim foundRange As Range
'get the source range
Set csvDataRange = Workbooks("Book2.csv").Sheets(1).Range("a:a") ' replace "Book2" with yourCSVfile.csv
'check for selection, only one cell, ceck that cell and exit, otherwise loop thru selection
If Selection.Count > 1 Then
'loop thru all selected cells, ignore empty cells
For Each selRange In Selection.SpecialCells(xlCellTypeConstants)
findSelection selRange, csvDataRange
Next
Else
findSelection ActiveCell, csvDataRange
End If
Set foundRange = Nothing
Set selRange = Nothing
Set csvDataRange = Nothing
End Sub
Function findSelection(selRange, csvDataRange)
'try to find it in the csv file
Set foundRange = csvDataRange.Find(selRange) 'if found, assign it to foundRange
'if no match highligh cut
If foundRange Is Nothing Then
selRange.Interior.ColorIndex = 34
Else
'if found, get the value in next cell
selRange.Offset(0, 1) = foundRange.Offset(0, 1)
End If
End Function -
ORA-29284: File read error
Good morning,
Need to do two flat file on a 2000 lien.
1 - Read a file. csv
2 - Keep it plain, unformatted information from a table
These are the steps I performed to achieve the first goal ...
1 - READING TEST FILE
CREATE OR REPLACE DIRECTORY PUBLIC_ACCESS AS 'C:\REPORTES_REY';
GRANT READ, WRITE ON DIRECTORY PUBLIC_ACCESS TO PUBLIC;
-- THIS PL / SQL works ok..
DECLARE
v1 utl_file.file_type;
v2 varchar2(600);
begin
v1:= utl_file.fopen('PUBLIC_ACCESS','prueba20110218.csv','R'); -- WORKS WELL ...
--v1:= utl_file.fopen('PUBLIC_ACCESS','sui_facturacion_alcantarillado_15085_2011_01_76845_001.csv','R');
loop
begin
utl_file.get_line(v1,v2);
dbms_output.put_line('el contenido del archivo es: '||v2);
exception
when no_data_found then
exit;
end;
dbms_output.put_line(' - '); JUMP LINE
end loop;
utl_file.fclose(v1);
exception
when others then
dbms_output.put_line(sqlerrm);
end;
but when you change the file name by map prueba20110218.csv de-> sui_facturacion_alcantarillado_15085_2011_01_76845_001.csv displays the following error
ORA-29284: File read error+
- this error to be?
I am grateful for the attention and cooperation extended ...
good day ...
REYNEL SALAZAR MARTÍNEZ
Cali-ColombiaThank you very much for your cooperation extended
The file if it exists, the operating system is Windows, I'm running for the line of command and the file is in the same direction as the file prueba20110218.csv
Segi therefore his advice and remove:
exception
when others then
dbms_output.put_line(sqlerrm);
then run the following code:
DECLARE
v1 utl_file.file_type;
v2 varchar2(800);
begin
v1:= utl_file.fopen('PUBLIC_ACCESS','prueba20110218.csv','R'); FUNCIONA BIEN...+
v1:= utl_file.fopen('PUBLIC_ACCESS','sui_facturacion_alcantarillado_15085_2011_01_76845_001.csv','R',32767);
loop
begin
utl_file.get_line(v1,v2);
dbms_output.put_line('el contenido del archivo es: '||v2);
exception
when no_data_found then
exit;
end;
dbms_output.put_line(' - '); SALTO DE LINEA+
end loop;
utl_file.fclose(v1);
exception
when others then
dbms_output.put_line(sqlerrm);
end;
+/+
ORA-06502: PL / SQL: error: character string buffer too small numeric or value
I do not understand the error -> ORA-06502
thanks...
good day
Reynel Salazar Martínez
Cali-Colombia -
Uncorrectable error detected by pci0... during DVMA read transaction
hi people... at first, sorry for my english. I hava a Sun Fire 280R with Solaris 8 and today it boot aparently without a reason, it boot 5 or 6 times. The error before the fall is:
WARNING: Uncorrectable error detected by pci0 (safari id 00000000.00000008) during DVMA read transaction
panic[cpu0]/thread = 2a10001fd20: Fatal PCI UE Error
syncing file systems... 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 done (not all i/o completed)
dumping to /dev/dsk/c1t0d0s1, offset 429588480
I can not make a backup and sometimes I can not logon because it cause the boot. I have reading something of this error and I have puting the machine in diagnostic mode:
auto-boot? = false
diag-device = disk
diag-level = max
diag-switch? = true
After this, power-off and after this I have igniting the machine... I have almost one hour waiting and no notice... the screen continue black :-(
Can somebody help me?
THANKS! Ceci.Ceci,
First off, <font color="firebrick">WRONG FORUM</font>.
This forum is for discussions of the <u>Live Upgrade procedure</u> of installing Solaris.
Period.
Having said that...
Diagnostic mode sends all console output to the TTYa port.
You will never see the diag results on your monitor.
Particularly for such a system as a 280R that was
never intended to run with a graphics card and keyboard/mouse.
Set up a TIP session and start the diag boot all over again.
Capture all the output to a file
You appear to have a hardware issue.
We can only guess what the real root cause might be
(third party adapter card? Solaris not patched?)
You would get the best guidance and analysis if you open a service case with Sun techsupport.
These forums are user-to-user discussions. This is NOT Sun techsupport. -
Zen goes blank during file transfer
i own a Zen 32GB flash player, and recently it has been going blank and forcing me to reset when i try to transfer files using the mediasource organizer. it connects fine, is recognized, and i can ever browse it, but when i try to transfer files the player goes from a "docked" screen to a blank one, the organizer reports an error, and i have to reset the player. this occurs with different files, so the cause isn't a faulty file. i am running the most recent version of MSO, and the latest drivers and firmware. OS is XP?sp2.
recovery mode cleanup also didn't help, and since the transfer rate is very slow i rather avoid formatting if i can.
has anyone experienced the same problem? any help would be appreciated.'Re: Zen goes blank during file transfer. I have also experienced this same problem. I am currently using Windows 7 RC with Windows Media Player 2, but it was previously happening when running Windows XP SP3 with WMP.
I have actually had my player replaced already since I had this same problem on my previous player. That started occurring after having had the player for around 4 months. On first occurring a reset and clean up from the recovery mode was enough to get it going again, at least for a week or so. It then started occurring more frequently and I was forced to format the device. Again this seemed to fix the problem initially, but after just a few days it got to the point where even that wouldn't get it working again, at which point I sent it back and received a new device.
I've now had my replacement device for only a few weeks and it's started to happen again. I haven't yet resorted to a format, but a cleanup isn't working.
From my observation it seems to be in some way related to general power issues with the device. When the problem occurs the screen goes off and the player isn't recognised by the PC, but the power light on the side of the device remains lit orange, so it hasn't actually turned off. I've also had ongoing problems, on both devices, where I often can't turn the player back on after either I've turned it off or it's gone through the auto power down after leaving it on pause. In that case I also have to reset the device via the side button, and then wait a few minutes for the library to rebuild.
I too would appreciate hearing from anyone who might be able to provide some help with this problem, because my initial workarounds as described only work for a short period of time and I would prefer not to have to send it back a second time. -
I'm encountering this error and not sure how to fix, I'm quite new to vCenter so please bear with me.
I'm trying out vCenter 5.1 with Update Manager 5.1 right now. No license key has been entered and I still have 50 odd days to try it out.
2 ESXi hosts are being managed by this vCenter, and they're both running ESXi 4.0
I'm looking to use Update Manager to try to upgrade the ESXi 4.0 hosts to ESXi 5.1
I downloaded the image file VMware-VIMSetup-all-5.1.0-799735.iso from VMWare website, and is looking to import it using the Update Manager so I can update the ESXi hosts, but I keep on getting the error:
File name: VMware-VIMSetup-all-5.1.0-799735.iso
Failed to transfer data
Error was: A web exception has occurred during file upload
I tried importing it by using vSphere client to connect to vCenter server both remotely and locally, with firewall disabled.
I've read http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1026602
I've disabled firewall, and there is no anti-virus program on the server. I've also restarted the machine several times, to no avail, I didn't reinstall update manager because the whole Windows and VCenter installations are clean from scratch.
I logged into the vSphere Client using Active Directory credentials, and I've made all Domain Admins (which my account is a member of) part of the administrator group on the vCenter server. I can't log in using admin@System-Domain because it tells me I don't have permissions for it, I still haven't really had the chance to figure out why that is and not sure if that makes a difference.
Also, I'm fairly certain I'm using the right image file, as I've burned some DVD's used that image file to upgrade some other ESXi hosts. Unless there's a special image file I need to download?
I'm at lost on what I can do to make it work. Please advise.
Thanks.The ISO file you mentioned is the one for vCenter Server. What you need is the "VMware-VMvisor-Installer-5.1.0-799733.x86_64.iso" (or VMware-VMvisor-Installer-201210001-838463.x86_64.iso) for the ESXi host.
André -
Purchased a new Apple TV and the remote double clicks each time I press the button. It worked fine during set up and for the first two days. I have since moved it and this problem started. Restarted,reset,unplugged,changed remotes, no change. Latest software update. This is really annoying. iPhone remote app works just fine. Any suggestions?
That's one of the weird things.. it recognizes it maybe 10% of the time. And usually, only after I do the two-button reset. Problem is.. since it won't charge above 2%, anytime I try to do a restore or anything like that using iTunes, my device shuts off and I lose whatever progress I'd made.
So, an update... after reading through a bunch of similar complaints (there are literally 1000's of them so there's NO WAY this isn't somehow ios7 related, thanks a lot APPLE ) I decided to try a restore in recovery mode. After 3 hours and several disconnections... I ended up having to just set it up as a new iPad, as the restore did nothing. Weirdly though... as I was doing the restore in recovery mode.. I noticed I'd gotten up to a 10% charge.. higher than it's been since September, so after setting it up as a new device, I turned it off and plugged it in using the wall charger. 2 hours later and I was up to 38%. Still not great, as my iPad, before ios7 could've fully charged twice in the amount of time it took for me to now get 28% more of a charge. And that's with a fully cleaned out device.. so that really ***** and I'm now more confused than ever.
But I'm gonna leave it overnight charging and see what I come up with tomorrow. Sadly, when I paid $600 for it in February, I never expected to have to play "wait and see" with it... -
Any way to have file size included in the first search in finder?
Is it possible to somehow show file sizes when doing a search in finder?
On Panther, it was very helpful to have the file sizes listed. This immediately revealed whether the photoshop files I was looking for were full size or reduced.
But when I run a search in Snow Leopard it only shows name, kind and last opened. Otherwise I have to also add a second search to add in file size.
Any way to have file size included in the first search?
Thanks!Well, I wish I could take credit for knowing it was there before two days ago... but I dropped my laptop a couple months ago and it finally died for good on Friday, and I noticed this on the new laptop when setting up my Finder preferences.
-
Removing first line in text file... Memory and HD concern
Hello all,
I want to remove the first line of a text file. This is easy... One way
to do it, is to find the first "end of line" caracter, strip the string
and re-write the sting in file with the "strip to sreadsheet" VI.
Since the file can be quite large (about 120000 lines), is this a good
way to do it. Will it re-write all the line or just moving the "begin
of file" pointer to the second line? If it re-write the whole file,
this option is not very good since I could have to do this operation
quite often. (I want the file to be a kind of circular buffer / backup).
What do you think is the best way to do this?
Thanks!
VincentI think you would have to read in all the data and write it to a new file, you could either keep the data in RAM or simply write to another file then delete the original, and then rename the temp one. So obviously that is a lot of data and memory.
My main question is are you trying to use a text file as a circular buffer? If so can you tell us more about the data, ie is it strings of a constant length? Does a user ever need to read the file or could we head binary?
A solution would be to truly make the file a binary file, so you could actually seek through the file easier, and maybe make the first data chunk the location of the most recent write. The obvious danger is then writing over existing data. This solution is still risky because of the data writes.
You may want to look at some of the other file formats like HWS which maintains a hierarchy of data for you so you can simply add and remove data from it. However, a user will not be able to easily read it.
Maybe you are looking for
-
Photoshop CS4 crashing (after Mavericks update?)
Hello! For some reason, this morning, every time I open Photoshop CS4 on my 15" Macbook Pro (June 2009), it crashes right away. It was letting me edit for about 10 seconds at first, but after a few restarts, it stopped letting me do anything at all.
-
Budget control - Assigned funds are less than payment budget for fiscal year in document item
Dear Experts, We are using Former budgeting, when ever we run the transaction FMBV getting the following message to a particular user. Budgeting Assigned funds are xxxx BHD less than payment budget for fiscal year 2014 in document item XXXX /XXXXX .
-
How to install OEM 10g using an existing database on another host
Hi, I've created a 10g database (on host solaris_x86) which I like to use for the OEM 10G GC (on host linux_x86). If I install OEM using existing DB, then the installer expect the database is running locally. If I install OEM using new DB, then the i
-
Itunes crashing since windows 8.1 update
Since I recently updated my laptop to windows 8.1 I can not connect to itunes. I keep getting a message: I tunes has stopped working I have unstalled and reinstalled the latest version of Itunes
-
Installing JSDK 1.4.1_02 on win 98
I'm new to Java and new to programming. To date downloaded Java from CD from course tutor and set path in autoexec.bat file according to instructions. Get meesage in DOS 'Bad Command.... when compiling the Hello progr.Any suggestions