Trying to read a file with Scanner
This is the code:
public void action(){
try{
Scanner sc = new Scanner(new FileReader("examples2.txt"));
String s;
while((s = sc.nextLine()) != null){
System.out.println(s);
catch(FileNotFoundException e){
System.out.println(e);
}Output:
java.io.FileNotFoundException: examples2.txt (The system cannot find the file specified)Can anyone figure out why I am getting an exception? I know for a fact that the file exists and it exists in the same package as my class. I don't understand why it can't find the file. I have considered case sensitivity.
Thanks
SquareBox wrote:
I would NOT be using Scanner for this type of io except that my assignment says that I have to. Just curious, why don't you like it?The API seems overly finicky to me; resulting in a lot of problems for newbies (at whom I understand the class was originally targeted) who end up using it incorrectly.
Mind you, it's possible that I'm just an old dinosaur who prefers to read lines and then decide what I want to do with them myself.
I tried this:
Scanner sc = new Scanner(new BufferedReader(new FileReader("examples2.txt")));
It works.What, when FileReader alone didn't? That seems odd.
If I do that then do I have to flush the buffer? Or does it get flushed on it's own?I doubt whether it matters; flushing is generally only needed for output.
Winston
Similar Messages
-
I can't read a file with the ext PDF the sender informed me that the file was reset to PDF.
I can't read a file with the .ext PDF the sender informed me that the file was reset to PDF. But when I tried to open it the caption box informed me"the file is not in PDF format. I suspect the sender simply changed the file .ext which is why I can't open it! What can I do about it! I am working on an iPad.
Thanks
Mr Jim LapthornIf the document is not, in fact, a PDF, then you will need to get your sender to provide a PDF.
Can you open this document in any other application? -
Why can't I read PDF files with this browser?
It says "can't read PDF files with this browser running. Exit and try again."
I have Adobe 9.3.2 installed. It didn't give me this message with earlier versions of Adobe.
Is there a way to go BACKWARDS?
How do I save the PDF files so I can close them and view them without using the browser?
== I downloaded later versions of Adobe.I have tried everything,Foxit and Foxit updates, Gone to Adobe......you think of it I have tried.
ONLY ANSWER THAT WORKS :
Download Internet Explorer 8 and use that -
Every time I am trying to open Quicktime files with my Quicktime it wants to convert the files. Why?
QuickTime version 10.3 will "convert" older legacy codecs into a more modern version. You can save this newer version and delete the older one.
This can only mean that support for those codecs will be removed completely some time in the future. -
I have a problem with the mac can not read video files with the extension IMOD. How can I solve this problem?
By doing a Google search.
-
Read a file with a variable=counter : NAMEFILE001,NAMEFILE002..
Hello,
I would need your councils.
I can read a logical file on my server(logical example of name: NAMEFILE) with function FILE_GET_NAME.
But I would like to be able to read a file with a counter i.e.
the first time: to read NAMEFILE001;
the second time read NAMEFILE002;
the third time read NAMEFILER003...
How made you that?
With function FILENAME_EXIT _?
But, where do I put the variable = counter? In a table...?
Thank you in advance of your answer
ServaneHi Servane,
You could also do the following:
in transaction FILE you set up the physical path name as follows:
/<i>path</i>/.../<FILENAME><PARAM_1>
then you call the function FILE_GET_NAME:
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
LOGICAL_FILENAME = W_LOGICAL_FILENAME
PARAMETER_1 = W_FILENUMBER
IMPORTING
FILE_NAME = THEFILE
EXCEPTIONS
FILE_NOT_FOUND = 1
OTHERS = 2.
This will equally construct the name/counter as you wish.
AND, if I am not wrong, since the system does it, you will not have to worry about putting the last counter value away in the DB.
cheers,
Phil
Message was edited by: Phillip Morgan -
Trying to read a file but doesnt know how to get the size of the inputstrem
hi im trying to read a file in a cel this is my code:
fconn = (FileConnection)Connector.open("file://localhost/" + actualdir);
InputStream fis = fconn.openInputStream();
byte b[] = new byte[1024];
fis.read(b);
fis.close();
fconn.close();
textBox1 = new TextBox("Viendo el Archivo: " + list1.getString(list1.getSelectedIndex()), null, 1024,TextField.ANY | TextField.UNEDITABLE);
textBox1.setString(new String(b, 0, b.length)); i dont want to create always an array of bytes of size 1024 instead i wanna know how many bytes does inputstream object has, how can i know that?you can either retrieve the whole file at once by determine the file size like:
fconn = (FileConnection)Connector.open("file://localhost/" + actualdir);
InputStream fis = fconn.openInputStream();
byte b[] = new byte[fconn.fileSize()];
fis.read(b);
fis.close();
fconn.close();
or read every single byte
fconn = (FileConnection)Connector.open("file://localhost/" + actualdir);
InputStream fis = fconn.openInputStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int i = fis.read();
while(i != -1){
baos.write(i);
fis.read();
String content = new String(baos.toByteArray()); -
Read multiples files with same extension
how to read multiples files with same extension in java.
for ex : i would like to read all .DAT files from C drive using java.
How is it done- You create the filter
- You get the list of files
- You open and read each file.
For the first two above you look at java.io.File and listFiles(FileFilter filter).
For the third you find whatever input stream is appropriate from java.io.* -
Reading large file with JCA Adapter in OSB
Hello,
We are searching for a solution how to read large file (>50M) from network drive and deliver it to queue via OSB 11gR4 (10.3.4). The problem is when reading the file with JCA File Adapter. It seems that it cannot handle as large files as we have. The documentation provides a way to bypass file size limitation by using Chunk Read but it seems to require BPEL Process execution which is not possible in our environment. Does anyone know if there are ways to implement this without having BPEL Process?
Our usecase:
read file from network drive -> transfer with OSB -> deliver MQ
Other options than JCA File Adapter can be considered, if anyone can advice...If it's a plain routing use case and no message processing is required then you may simply use OSB's FILE transport instead of JCA adapter. Create a messaging type proxy service and select request message type as "binary". Also enable the content streaming (Disk buffer, compression).
From OSB Dev guide -
Oracle JCA Adapter for FTP and Files – Attachments (large payload support), pre- and post-processing of files, using a re-entrant valve for processing ZIP files, content streaming, and file chunked read are not supported with Oracle Service Bus.
http://download.oracle.com/docs/cd/E17904_01/doc.1111/e15866/jca.htm#BABBICIA
You may also refer -
Reading huge flat file in OSB 11gR1
Regards,
Anuj -
Hi Folks,
How to read & write files with same extension(like ".sas", ".txt" , ".csv",and ".log" in Adobe AIR.
Please let me tell if anybody knows asap.
Thanks & Regards,
AndersonThanks Jon,
But, I know how to read the file if we give exact file path
I need to get the path and read file(s) with same extension files in the same folder using adobe air, not single file.
Don't have file path even, i have folder path, in that somany files are there. So i need to get which are the same extension(Ex: ".txt", ".sas") files
If you have any idea , please help me out
Regards,
Vijay. -
hello all,
I've this XML file:
<?xml version="1.0" standalone="yes"?>
<Configurations>
<PageConfigurations softwareCode="63720415" softwareVersion="07" />
<Page pageName="PAGE1">
<description>DESC1</description>
<Param>
<name>TaskMulti_guc</name>
<address>1128203</address>
<nameType>C</nameType>
<size>1</size>
<offset>0</offset>
<format>Hexadecimal</format>
<description>description</description>
<adminReadonly>false</adminReadonly>
<userReadonly>true</userReadonly>
<byteNumber>4</byteNumber>
<gainK1>1</gainK1>
<gainK2>1</gainK2>
<offsetScale>0</offsetScale>
<switchName />
<switchAddress />
<switchType />
<switchSize>1</switchSize>
<switchOffset>0</switchOffset>
<switchByteNumber>4</switchByteNumber>
<switchValue>0</switchValue>
<switchTime>Before</switchTime>
<switchReset>false</switchReset>
<debugName />
<debugAddress />
<debugType />
<debugSize>1</debugSize>
<debugOffset>0</debugOffset>
</Param>
<Param>
<name>TempNum_guh</name>
<address>1124743</address>
<nameType>H</nameType>
<size>1</size>
<offset>0</offset>
<format>Hexadecimal</format>
<description>description</description>
<adminReadonly>false</adminReadonly>
<userReadonly>true</userReadonly>
<byteNumber>4</byteNumber>
<gainK1>1</gainK1>
<gainK2>1</gainK2>
<offsetScale>0</offsetScale>
<switchName />
<switchAddress />
<switchType />
<switchSize>1</switchSize>
<switchOffset>0</switchOffset>
<switchByteNumber>4</switchByteNumber>
<switchValue>0</switchValue>
<switchTime>Before</switchTime>
<switchReset>false</switchReset>
<debugName />
<debugAddress />
<debugType />
<debugSize>1</debugSize>
<debugOffset>0</debugOffset>
</Param>
<Param>
<name>vMylifeSignal_guc</name>
<address>1131388</address>
<nameType>C</nameType>
<size>1</size>
<offset>0</offset>
<format>Hexadecimal</format>
<description>description</description>
<adminReadonly>false</adminReadonly>
<userReadonly>true</userReadonly>
<byteNumber>4</byteNumber>
<gainK1>1</gainK1>
<gainK2>1</gainK2>
<offsetScale>0</offsetScale>
<switchName />
<switchAddress />
<switchType />
<switchSize>1</switchSize>
<switchOffset>0</switchOffset>
<switchByteNumber>4</switchByteNumber>
<switchValue>0</switchValue>
<switchTime>Before</switchTime>
<switchReset>false</switchReset>
<debugName />
<debugAddress />
<debugType />
<debugSize>1</debugSize>
<debugOffset>0</debugOffset>
</Param>
</Page>
<Page pageName="PAGE2">
<description>DESC2</description>
<Param>
<name>TaskMulti_guc</name>
<address>1128203</address>
<nameType>C</nameType>
<size>1</size>
<offset>0</offset>
<format>Hexadecimal</format>
<description>description</description>
<adminReadonly>false</adminReadonly>
<userReadonly>true</userReadonly>
<byteNumber>4</byteNumber>
<gainK1>1</gainK1>
<gainK2>1</gainK2>
<offsetScale>0</offsetScale>
<switchName />
<switchAddress />
<switchType />
<switchSize>1</switchSize>
<switchOffset>0</switchOffset>
<switchByteNumber>4</switchByteNumber>
<switchValue>0</switchValue>
<switchTime>Before</switchTime>
<switchReset>false</switchReset>
<debugName />
<debugAddress />
<debugType />
<debugSize>1</debugSize>
<debugOffset>0</debugOffset>
</Param>
<Param>
<name>TaskMulti_guc</name>
<address>1128203</address>
<nameType>C</nameType>
<size>1</size>
<offset>0</offset>
<format>Hexadecimal</format>
<description>description</description>
<adminReadonly>false</adminReadonly>
<userReadonly>true</userReadonly>
<byteNumber>4</byteNumber>
<gainK1>1</gainK1>
<gainK2>1</gainK2>
<offsetScale>0</offsetScale>
<switchName />
<switchAddress />
<switchType />
<switchSize>1</switchSize>
<switchOffset>0</switchOffset>
<switchByteNumber>4</switchByteNumber>
<switchValue>0</switchValue>
<switchTime>Before</switchTime>
<switchReset>false</switchReset>
<debugName />
<debugAddress />
<debugType />
<debugSize>1</debugSize>
<debugOffset>0</debugOffset>
</Param>
</Page>
<Page pageName="PAGE3">
<description>DESC3</description>
<Param>
<name>TaskMulti_guc</name>
<address>1128203</address>
<nameType>C</nameType>
<size>1</size>
<offset>0</offset>
<format>Hexadecimal</format>
<description>description</description>
<adminReadonly>false</adminReadonly>
<userReadonly>true</userReadonly>
<byteNumber>4</byteNumber>
<gainK1>1</gainK1>
<gainK2>1</gainK2>
<offsetScale>0</offsetScale>
<switchName />
<switchAddress />
<switchType />
<switchSize>1</switchSize>
<switchOffset>0</switchOffset>
<switchByteNumber>4</switchByteNumber>
<switchValue>0</switchValue>
<switchTime>Before</switchTime>
<switchReset>false</switchReset>
<debugName />
<debugAddress />
<debugType />
<debugSize>1</debugSize>
<debugOffset>0</debugOffset>
</Param>
</Page>
</Configurations>
with this class:
public class Page
public string PageName { get; set; }
public string Description { get; set; }
public List<Param> List = new List<Param>();
public class Param
public string Name { get; set; }
public string Address { get; set; }
public string Format { get; set; }
public string Description { get; set; }
How can I read this file with LINQ (I'm no expert) for fill correctly my object ?
Thanks in advance.
StefanoPlease refer to the following sample code:
XDocument doc = XDocument.Load("c:\data1.xml");
List<Page> pages = new List<Page>();
var pageElems = doc.Root.Elements("Page");
foreach (var page in pageElems)
Page pageObj = new Page();
pageObj.PageName = page.Attribute("pageName").Value;
pageObj.Description = page.Element("description").Value;
pageObj.List = new List<Param>();
var paramElems = page.Elements("Param");
foreach(var paramElem in paramElems)
Param paramObj = new Param();
paramObj.Address = paramElem.Element("address").Value;
paramObj.Description = paramElem.Element("description").Value;
pageObj.List.Add(paramObj);
pages.Add(pageObj);
The code adds the Page objects to the pages list.
Please remember to close your threads by marking all helpful posts as answer and then start a new thread if you have a new question. -
I have a question, but I posted it on the wrong forum. This is the link:
https://social.msdn.microsoft.com/Forums/en-US/899c8291-70f5-4c1b-abf2-a1a1242e017a/read-xml-file-with-counter?forum=visualstudiogeneral&prof=requiredHi,
I have created a program that read an xml file like this:
<xas>
<information>
<list>"12345"</list>
<version>1.0.0.1</version>
</information>
<word><n>0</n><v>test123v</v><a>test123a</a></word>
<word><n>1</n><v>testv</v><a>testa</a></word>
</xas>
I read it to a listview called listview1:
The MainWindow.xaml:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="" Height="1220" Width="1017" WindowStartupLocation="Manual" ScrollViewer.HorizontalScrollBarVisibility="Visible" ScrollViewer.CanContentScroll="True" UseLayoutRounding="False" WindowState="Maximized">
<Grid>
<ListView x:Name="ListView1" HorizontalAlignment="Left" Height="1220" VerticalAlignment="Top" Width="1017">
<ListView.View>
<GridView x:Name="Lijst">
<GridViewColumn x:Name="Vraag" Header="Vraag" DisplayMemberBinding="{Binding Vraag}">
</GridViewColumn>
<GridViewColumn x:Name="Antwoord" Header="Antwoord" DisplayMemberBinding="{Binding Antwoord}">
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</Grid>
</Window>
And this is MainWindow.xaml.vb:
Imports System.IO
Imports System.Reflection.Assembly
Imports System.Xml
Imports System.Data
Class MainWindow
Dim VraagListBox As New ListBox
Dim AntwoordListBox As New ListBox
Dim Hoofdmap As String = GetExecutingAssembly().Location
Dim Bestand As String
Private Sub MainWindow_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
'RUNNEN MAAR!!!!
'Het bestand vinden in de commandline argumenten
Dim args() As String = System.Environment.GetCommandLineArgs()
Dim Teller As Integer = "0"
For Each arg As String In args
If Teller = "1" Then
Bestand = arg
Else
Teller = Teller + "1"
End If
Next
Bestand = "D:\Alles voor school!\Alles voor school!\Vakken\Stepping Stones\DATA1\Hoofdstuk 1\Leerlijsten\Hoofdstuk 1 Grammer 1.xas"
'Welk bestand? Set de title
Me.Title = Path.GetFileName(Bestand) & " - ListViewer (V.1.0.0.6)"
If Bestand <> "" Then
'Vragen en antwoorden toevoegen in de kolommen
If Path.GetExtension(Bestand) = ".xas" Then
Dim orderInfo = XElement.Load(Bestand)
For Each entry As XElement In orderInfo...<word>
Dim thisOrder As New Order
With thisOrder
.Vraag = entry...<v>.Value
.Antwoord = entry...<a>.Value
End With
ListView1.Items.Add(thisOrder)
Next
'Virtuele vraaglistbox toevoegen = kolom Vraag van LisView1
Dim orderInfoVraag = XElement.Load(Bestand)
For Each entry As XElement In orderInfoVraag...<word>
Dim thisOrderVraag As New VraagClass
With thisOrderVraag
.Vraag = entry...<v>.Value
End With
VraagListBox.Items.Add(thisOrderVraag)
Next
'Virtuele antwoordlistbox toevoegen = kolom Antwoord van LisView1
Dim orderInfoAntwoord = XElement.Load(Bestand)
For Each entry As XElement In orderInfoAntwoord...<word>
Dim thisOrderAntwoord As New AntwoordClass
With thisOrderAntwoord
.Antwoord = entry...<a>.Value
End With
AntwoordListBox.Items.Add(thisOrderAntwoord)
Next
'Check wat er fout is aan het bestand, en geef een melding
Else
MessageBox.Show("Er is een verkeerde extentie geselecteerd, namelijk: " & Path.GetExtension(Bestand) & ".", "Verkeerde extentie - ListViewer", MessageBoxButton.OK, MessageBoxImage.Error)
Me.Close()
End If
Else
If Bestand = "" Then
MessageBox.Show("Je hebt geen bestand geselecteerd", "Geen bestand geselecteerd - ListViewer", MessageBoxButton.OK, MessageBoxImage.Error)
Me.Close()
Else
MessageBox.Show("Er is iets misgegaan met het laden van het bestand, probeer het later opnieuw", "Onbekende error - ListViewer", MessageBoxButton.OK, MessageBoxImage.Error)
Me.Close()
End If
End If
End Sub
Private Sub ListView1_MouseDoubleClick(sender As Object, e As MouseButtonEventArgs) Handles ListView1.MouseDoubleClick
Directory.CreateDirectory(Path.GetTempPath & "110% Soft\ListViewer 1.0.0.6\" & Path.GetFileName(Bestand))
Dim SchrijfVraag As New StreamWriter(Path.GetTempPath & "110% Soft\ListViewer 1.0.0.6\Word.txt")
Dim SchrijfFile As New StreamWriter(Path.GetTempPath & "110% Soft\ListViewer 1.0.0.6\File.txt")
SchrijfVraag.WriteLine(ListView1.SelectedIndex)
SchrijfFile.WriteLine(Bestand)
SchrijfVraag.Close()
SchrijfFile.Close()
Dim WoordenScherm As ViewWord
WoordenScherm = New ViewWord()
WoordenScherm.ShowDialog()
End Sub
End Class
ViewWord.xaml is:
<Window x:Class="ViewWord"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="ViewWord" Height="155" Width="1017" ResizeMode="NoResize" SizeToContent="WidthAndHeight" Topmost="True" WindowStartupLocation="CenterScreen">
<Grid>
<Label x:Name="VraagLabel" Content="Vraag:" HorizontalAlignment="Left" Margin="23,11,0,0" VerticalAlignment="Top" Width="106"/>
<TextBox x:Name="VraagTextBox" HorizontalAlignment="Left" Height="24" Margin="134,13,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="743" />
<Label x:Name="AntwoordLabel" Content="Antwoord:" HorizontalAlignment="Left" Margin="23,42,0,0" VerticalAlignment="Top" Width="106"/>
<TextBox x:Name="AntwoordTextBox" HorizontalAlignment="Left" Height="24" Margin="134,44,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="743"/>
<Button x:Name="VraagAanpassenButton" Content="Aanpassen" HorizontalAlignment="Left" Margin="882,15,0,0" VerticalAlignment="Top" Width="107"/>
<Button x:Name="AntwoordAanpassenButton" Content="Aanpassen" HorizontalAlignment="Left" Margin="882,44,0,0" VerticalAlignment="Top" Width="107"/>
<Label x:Name="VraagNummerLabel" Content="Vraagnummer:" HorizontalAlignment="Left" Margin="23,72,0,0" VerticalAlignment="Top" Width="106"/>
<TextBox x:Name="VraagNummerTextBox" HorizontalAlignment="Left" Height="24" Margin="134,74,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="743"/>
<Button x:Name="VraagNummerAanpassenButton" Content="Aanpassen" HorizontalAlignment="Left" Margin="882,74,0,0" VerticalAlignment="Top" Width="107"/>
</Grid>
</Window>
In VraagTextBox must come the entry <word><v>test123v</v></word>, in AntwoordTextBox must come the entry <word><a>test123a</a></word>, and in VraagNummerTextBox must come the entry <word><n>0</n></word>
This is the code to fix that (ViewWord.xaml.vb):
Imports System.IO
Public Class ViewWord
Private Structure AntwoordVraag
Public Vraag As String
Public Antwoord As String
End Structure
Private Sub ViewWord_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
End Sub
Private Sub AntwoordAanpassenButton_Click(sender As Object, e As RoutedEventArgs) Handles AntwoordAanpassenButton.Click
Dim Vraagnummer As String
Dim Bestandsnaam As String
Dim LeesVraag As New StreamReader(Path.GetTempPath & "110% Soft\ListViewer 1.0.0.6\Word.txt")
Dim LeesFile As New StreamReader(Path.GetTempPath & "110% Soft\ListViewer 1.0.0.6\File.txt")
Vraagnummer = LeesVraag.ReadLine()
Bestandsnaam = LeesFile.ReadLine()
LeesVraag.Close()
LeesFile.Close()
MessageBox.Show(Vraagnummer)
Dim teller As Integer = 0
Dim orderInfo = XElement.Load(Bestandsnaam)
If teller = Vraagnummer Then
VraagNummerTextBox.Text = orderInfo...<word>...<n>.Value
VraagTextBox.Text = orderInfo...<word>...<v>.Value
AntwoordTextBox.Text = orderInfo...<word>...<a>.Value
Else
teller = teller + 1
End If
End Sub
End Class
But the result isn't:
VraagTextBox.Text = testv
AntwoordTextBox.Text = testa
NummerTextBox.Text = 1
if i click on the number 2 of the listview (index = 1)
How can i fix it? -
Can we read Money files with iCompta?
Can we read Money files with iCompta?
Yes and no. I f you mean reading multiple files as one-single-payload to a process, you can not use this. But the file adapter reads all the files (depending on the number of agents) almost at once, processing each file, or each line in the file as a process instance.
Marc -
Can someone please tell me how I can convert video files with an extension of IDI_DVD to a file itunes and imovie can read? Thanks.
Thanks for the reply, The files are on a DVD disk. I coverted my family VHS tapes to digital dvds using an HP Media Centre PC five or more years ago cant remember the program but if I get info on the disk ,on the Mac it tells me the extension is IDI_DVD.
-
Opening a file with Scanner FUNNY CODE
public class ScanXan {
public static void main(String[] args) throws IOException {
Scanner s = null;
Scanner t = null;
try {
s = new Scanner(new BufferedReader(new FileReader("cd79.txt")));
t = new Scanner(new BufferedReader(new FileReader("local41.txt")));
while (s.hasNext()) {
String tempS = s.next();
while (t.hasNext()){
if (tempS.equals(t.nextLine())) {
System.out.println("Repeated: " + t.next());
catch (IOException e) {
e.printStackTrace();
finally {
if (s != null) {
s.close();
ANYTHING WRONG WITH THIS? I'M TRYING TO COMPARE THE FIRST LINE OF A TXT FILE WITH ALL THE lines from the other file. HOWEVER, When i run it, t.hasNext() STARTS READING FROM THE 4TH LINE OF THE FILE.
I can't figure it out. help please
thanks
Edited by: lsn67a02j3 on Mar 21, 2009 7:35 PM
Edited by: lsn67a02j3 on Mar 21, 2009 7:38 PM(When you post code, use the "code" tags. Either highlight your code and click the button with the label "CODE" or put {code} at the start of your code and the same thing again at the end. This makes the code readable.)
When i run it, t.hasNext() STARTS READING FROM THE 4TH LINE OF THE FILEHow do you know this? It is often a good idea to lard your code with System.out.println() statements (or use a debugger) so that you can tell, objectively, what is happening. It may help, too, to make sure your two input files are chosen so that they have readily identifiable lines.
while (s.hasNext()) {
String tempS = s.next();
while (t.hasNext()){This looks odd. You want to compare the line returned by s with all of the lines returned by t. But think about what will happen the second time around the loop: t.hasNext() is going to be false right from the start. It would be better to create a new Scanner each time around the outer loop.
if (tempS.equals(t.nextLine())) {
System.out.println("Repeated: " + t.next());
}In the event of a match this results in two scanner "next" calls. Is this what you mean to do?
Maybe you are looking for
-
Error while Result Recording-QM
Dear friends, While RR for inspection lot I faced this error. Characteristic results cannot be recorded for inspection lot 06000000764 Message no. QE181 Diagnosis You cannot record any characteristic results for this inspection lot. The material mast
-
I have bought a apple ipad 1st generation and I would like to put my ebooks on how would I do this the ibook app will not download on this ipad many thanks for any help offered
-
Also, when I tried to download either Firefox 3 or 4 from your site, I was informed the app was "corrupt." Any suggestions?
-
Delivery and read receipts from mail - how do i do it?
delivery and read receipts from mail - how do i do it? i used to do this on pc from outlook..... just new at this stuff... thanks
-
I like the framework and the ease of use. Does anyone know to what degree the search engines will evaluate the spry tags, if at all? My guess is that a hybrid will be needed as discussed at the bottom of this page: http://labs.adobe.com/technologies/