java,logic,bufferedreader,filereader
If you want to read the entire file twice, you will have to close it and open new streams/readers next time. Those streams/readers should be local to the method, not members, and certainly not static. ...
java,jsp,bufferedreader,eclipse-kepler
You can achieve it this way: while ((line = reader.readLine()) != null) { if (line.trim().length() == 0) { continue; } if (line.equals("Success")) { break; } else { // perform required operation } } ...
java,file,file-io,bufferedreader
If you care about the memory wasted in the intermediate StringBuffer, you can try the following implementation: public static void skipLine(BufferedReader br) throws IOException { while(true) { int c = br.read(); if(c == -1 || c == '\n') return; if(c == '\r') { br.mark(1); c = br.read(); if(c != '\n')...
As my above comment , you need to set user agent header by setRequestProperty method as below. String a = "http://kissanime.com"; URLConnection connection = new URL(a).openConnection(); connection .setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11"); connection.connect(); BufferedReader r = new BufferedReader(new InputStreamReader(connection.getInputStream(), Charset.forName("UTF-8"))); StringBuilder sb =...
java,image,image-processing,bufferedreader
Hi here I am writing multiple lines on JPanel. And you can write code which create Image from JPanel. package Stakeoverflow.swingFrame; import java.awt.Color; import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.image.BufferedImage; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; import...
java,unicode,encoding,inputstream,bufferedreader
UTF-8 is a multi-byte encoding. That means that one character might have a representation that is more than one byte long, especially if it is not a US-ASCII kind of character. You are specifically decomposing the string into bytes for reasons that are not clear, and appending them. So you...
java,eclipse,exception,bufferedreader,try-catch-finally
Both code examples should have compiler errors complaining about an unhandled IOException. Eclipse shows these as errors in both code examples for me. The reason is that the close method throws an IOException, a checked exception, when called in the finally block, which is outside a try block. The fix...
java,bufferedreader,filereader
Your understanding of how this block should work: The while loop goes through each line of text until the condition is no longer true Correct :-) . Each line is stored in the BufferedReader Not correct. The bufferedReader does not store any data, it just reads it (Thats why it's...
You need to specify the encoding to be able to read the russian character. Don't use FileReader as it will use default platform encoding. Instead use new BufferedReader(new InputStreamReader(fileDir), "UTF8"); ...
java,bufferedreader,bufferedwriter
try this: public class test1 { public static void main(String args[]) throws IOException{ StringBuffer sb = new StringBuffer(); String filepath = "test.txt"; List<String> list = new ArrayList<String>(); list.add("1"); list.add("2"); list.add("3"); list.add("4"); list.add("5"); list.add("6"); Iterator<String> it = list.iterator(); while(it.hasNext()) { sb.append(it.next()); sb.append(","); } BufferedWriter bw = new BufferedWriter(new FileWriter(filepath)); bw.write(sb.toString()); bw.flush();...
java,android,bufferedreader,fileinputstream,filechannel
Try following code. File sdCard = Environment.getExternalStorageDirectory(); File dir = new File(sdCard.getAbsolutePath() + File.separator + "/imotax"); dir.mkdirs(); File f= new File(dir, fileToCreate); if(!f.exists()){ f.createNewFile(); } fis = new FileInputStream(f); ...
While debugging found that "connection reset" was happening in middle hence data lose. Handled the exception to make a controlled retry for the same request and problem got resolved. Hope it helps to somebody.
You only read the first line. The line variable didn't change in the while loop, leading to the infinite loop. Read the next line in the while condition, so each iteration reads a line, changing the variable. BufferedReader br = new BufferedReader (new FileReader ("num.txt")); String line; while( (line =...
java,file,javafx,line,bufferedreader
As it turned out in the discussion, the problem is that with readLine() the following files will behave the same way: File A: "Hello\n" File B: "Hello" 1st readLine() --> "Hello" 2nd readLine() --> null ==> we cannot know if there was a '\n' after the last line or not...
To append to existing file use FileWriter with append = true argument in constructor: FileWriter fileWriter= new FileWriter(fileName,true); BufferedWriter bufferWriter = new BufferedWriter(fileWriter); bufferWriter.write(inputString); bufferWriter.close(); Read more about FileWriter here...
If you change BufferedReader() to BufferedReader[] it is possible: BufferedReader[] b = new BufferedReader[5];//<-- correct size declaration of array b[0] = new BufferedReader(new FileReader("foo")); BufferedReader(5) results in a compiler error in your IDE.....
Pass the BufferedReader into your method(s) (or make it a shared field), that way you don't have to re-create it. Also, you are correct that closing System.in (or something wrapping System.in) will cause you issues. Instead of public void foo() something like public void foo(BufferedReader reader) ...
Try the while loop while reading using BufferedReader: while ((savedChar = brSave.readLine()) != null) { System.out.println(savedChar); } If your files Contains text it will definitely show: Do not also leave the BufferedReader Open. Once you are done reading Close it: if (brSave != null)br.close(); ...
You should use Scanners for this. Here is an example implementing scanners: Scanner scanner = new Scanner(System.in); String s = scanner.nextLine(); String s2 = scanner.nextLine(); System.out.println(s + ":" + s2); //Close scanner when finished with it: scanner.close(); Here is the full documentation for further reading and examples: Oracle documentaion...
java,arrays,bufferedreader,java-io
public class Pool { private int teamCounter; ... public Pool(String aName) { super(); this.poolName = aName; this.teams = new Team[NOOFTEAMS]; teamCounter=0; } ... public void loadTeams() { ... //somewhere here I need to add the aTeam object to the array this.teams[teamCounter++]=aTeam; } } ...
java,iterator,hashmap,hex,bufferedreader
here is your code modified to read the file and populate a HashMap, in this case I am using a TreeMap to sort the hex fields in order, see if this works for you, public class FP extends JFrame implements ActionListener { private TreeMap<String, String> buttonColors; // Constructor public FP()...
java,text,bufferedreader,filereader
So the entire file is just one line? If that is the case, all you would have to do is the following: import java.util.Scanner; import java.io.*; public class convertToNewline { public static void main(String[] args) throws IOException { File file = new File("text.txt"); File file2 = new File("textNoCommas.txt"); PrintWriter writer...
Okay, here it is... Using this library should solve your problem: https://code.google.com/p/ez-vcard/ --- approach using your InputStreamReader (more exactly: Reader) VCard vcard = Ezvcard.parse(reader).first(); (where reader is of Type "Reader", which InputStreamReader is) and export it to JSON with the following snippet: String json = Ezvcard.writeJson(vcard).go(); ...
java,android,url,bufferedreader
How do you know that it's only half of the response? If you rely on what is printed with System.out.println() then you should be aware that Logcat has a limitation that prevents it from printing more than 4,000 characters. Anything after that is truncated. To check how much of the...
Something like: line = it.nextLine(); if (line.contains("specific string")) continue; test = StringUtils.split(line,(",")); Why are you using StringUtils to split a line? The String class supports a split(...) method. I suggest you read the String API for basic functionality....
java,bufferedreader,filereader
I was able to find that bug very easily, when you get NullPointerException always try to print it out in the console before doing something to it, just to make sure. I've just added System.out.println(line) before Integer.parseInt(), remember to do this and it will make your life much much easier...
java,inputstream,bufferedreader
This kind of question already answered : http://stackoverflow.com/a/15799469/3480200 With some opinion from others i conclude that: It's not ok to use buffered inside another buffered in my case. It's useless....
java,nullpointerexception,null,bufferedreader
You're setting the value to null explicitly: String[] returnVal = null; Since you don't know how many elements it'll contain, you should use an ArrayList instead*: ArrayList<String> returnVal = new ArrayList<>(); * See the API to know what methods you should use to add objects to it...
java,java.util.scanner,bufferedreader
@EJP's answer is spot on. I just want to add that code that attempts to use the ready() method of input streams and readers is usually broken in one way or another. And in this case, the ready() call is not achieving anything useful. It is better to just call...
java,bufferedreader,infinite-loop,inputstreamreader
The idiomatic way to read all of the lines is while ((line = buffer.readLine()) != null). Also, I would suggest a try-with-resources statement. Something like try (InputStreamReader instream = new InputStreamReader(System.in); BufferedReader buffer = new BufferedReader(instream)) { long length = 0; String line; while ((line = buffer.readLine()) != null) {...
java,process,bufferedreader,handbrake
Call builder.redirectErrorStream(true); before creating the process (this will merge the input and the error stream into one: the input stream), and only read from the InputStream. That should solve the problem of the error stream running out of data before the input stream. If you do want to keep them...
java,bufferedreader,filereader,filewriter,bufferedwriter
The for loop work like this.To read the data back, you could read the whole string example: weapon1,item2,item99 into a String object and then split the String with a delimiter "," using split function of string class and then build the new array.example. String text="weapon1,item2,item99"; String parts[]=text.split(","); for(int i=0;i<parts.length();i++) Inventory.add.parts[i]...
java,bufferedreader,bufferedwriter
you are reading the file and at the same time writing contents on it..it is not allowed... so better way to read the file first and store the processed text in another file and finally replace the original file with the new one..try this br = new BufferedReader(new FileReader("C:\\Users\\Chris\\Desktop\\file_two.txt")); bw...
java,file,while-loop,bufferedreader,readline
It would be much easier to do with a Scanner, where you can just set the delimiter: Scanner scan = new Scanner(new File("/path/to/file.txt")); scan.useDelimiter(Pattern.compile(";")); while (scan.hasNext()) { String logicalLine = scan.next(); // rest of your logic } ...
java,arrays,file,java.util.scanner,bufferedreader
byte[] inputBytes = "line 1\nline 2\nline 3\ntok 1 tok 2".getBytes(); Reader r = new InputStreamReader(new ByteArrayInputStream(inputBytes)); BufferedReader br = new BufferedReader(r); Scanner s = new Scanner(br); System.out.println("First line: " + br.readLine()); System.out.println("Second line: " + br.readLine()); System.out.println("Third line: " + br.readLine()); System.out.println("Remaining tokens:"); while (s.hasNext()) System.out.println(s.next()); and add a while...
java,html,url,character-encoding,bufferedreader
The Server has changed his transfer mode to compressed data, what you can see in response header from server: Connection:keep-alive Content-Encoding:gzip Content-Type:text/html; charset=utf-8 Date:Mon, 09 Mar 2015 09:34:41 GMT Server:nginx Transfer-Encoding:chunked Vary:Accept-Encoding X-Powered-By:PHP/5.5.16-pl0-gentoo As you can see the content encoding is set to gzip Content-Encoding:gzip. So you have to decode...
java,console,line,bufferedreader
I made a simple programm and it worked with Eclipse by just changing the System.out.println(...) to System.out.print(...). But you will have the problem to separate the numbers e.g. Enter number(s): 1 2 3 will return 1 2 3 as one string. Therefore I would suggest you to use a Scanner...
java,android,sockets,bufferedreader,data-transfer
The answer is in the comments. The transfer of file name and size and using a sleep() is no good. You now send for instance myfile.txt:3456. But you better send a line like myfile.txt:3456\n and remove the sleep(). Then in the client you use readLine() to read the line. Also...
java,loops,directory,bufferedreader,inputstreamreader
I can see you want to read the content into another file... the following classes are used for writing/reading data to files. FileOutputStream,FileInputStream; as you can see, FileOuputStream is used in writing data to a file and FileInputStream is used in reading data from a file. the data can be...
java,algorithm,file,bufferedreader
You can count the lines in the template.. store the 1st and nth value loop the file content if 1 or n matches with the line number .. store them separately... perform string manipulations... append all variable and write them into another file......
java,string,bufferedreader,filereader
You're breaking the loop if the name exists, so you should only print the "not exists" message if the loop doesn't break: Scanner in = new Scanner(System.in); out.print("Enter name: "); String name = in.nextLine(); BufferedReader br = new BufferedReader(new FileReader("name.txt")); String line; boolean nameFound = false; while ((line = br.readLine())...
Stop trying to build up aisLines as a big String. Use an ArrayList<String> that you append the lines on to. That takes 0.6% the time as your method on my machine. (This code processes 1,000,000 simple lines in 0.75 seconds.) And it will reduce the effort needed to process the...
java,filter,inputstream,bufferedreader,inputstreamreader
Assuming there's only one : symbol in the string you can go with id = ligne.substring(ligne.lastIndexOf(':') + 1); ...
java,bufferedreader,filereader,ini,ini4j
When you want to load the config from the jar, you can use the path getResource() and getResourceAsStream() functions. The NullPointerException indicates (most likely, because it is always hard to tell with many statements on one line) that the resource was not found (which silently returns null) If you want...
java,arraylist,static,bufferedreader
You declared all properties of Employee_Info as static fields. These are not bound to an instance of the class but rather to the class itself. Therefore, all instances of the class share the same values. Remove the static keyword from both the fields and the methods. You should use an...
java,dictionary,hashmap,bufferedreader,filereader
The space characters around the number caused a NumberFormatException, and there are space characters around city names so change this line amap.put(pair[i], Integer.parseInt(pair[1 + i])); to this amap.put(pair[i].trim(), Integer.parseInt(pair[1 + i].trim())); It's a really bad practice to leave catch blocks empty, it hides the problem (the NumberFormatException in this case)....
android,web-services,pdf,bufferedreader,filereader
I am trying to download and open a PDF file inside android application i.e. without using any other application(pdf viewer,etc) installed on phone. Not according to the code in your question. You are specifically attempting to open the PDF file in "other application(pdf viewer,etc) installed on phone". Using the...
java,arrays,file,bufferedreader,bufferedwriter
Have a look at these modifications, you would want to replace data1 right after you detect it's different, then just read the rest of the lines and append them to your StringBuilder public static void main(String[] args) throws Exception { test("aaa", "bbb"); } public static void test(String DATA1, String DATA2)...
java,input,system,bufferedreader,println
System.in is a BufferedInputStream, such a Stream can be any input stream (for instance a network socket, or a file), but also the standard input channel stdin. stdin is the content you type in the command line, so obviously, it doesn't show anything. When you create a Scanner as shown...
You get a null only when you have exhausted the stream. But the first line of the stream (your file) is just an empty line - and you load it, the result of the empty line, is an empty string (""). It can be easily solved by skipping lines with...
java,bufferedreader,jfilechooser
This code snippet should be a solution to your problem. printLines is used to start printing lines after your organism has been found. The while loop continues round and if another organism is not found, then the line is printed. But when a new organism is reached (denoted by >...
java,linked-list,bufferedreader,stringtokenizer,parseint
I would just use try-catch: ArrayList<Integer> nums = new ArrayList<Integer>(); String lastLine = ""; try { while ((lastLine = in.readLine()) != null) { StringTokenizer st2 = new StringTokenizer(lastLine); graph.addEdge(Integer.parseInt(st2.nextToken()), Integer.parseInt(st2.nextToken())); } } catch (NumberFormatException e) {} System.out.println(lastLine); ...
All you need to do is just to split each line using whitespace as a delimiter and keep the first token, and repeat that for every line: This can be achieved using the following line of code which uses the split function (see more info here http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#split(java.lang.String)) line.split("\\s+"); Then, the...
Define BufferedReader at instance level just after declaring your path variable like BufferedReader buff; And in your method open, initialize it like buff = new BufferedReader(read); ...
java,arrays,file,bufferedreader
Please try this code: public static void main(String[] args) { BufferedReader reader = null; String line; String name,pwd,contactNo,email; try { reader = new BufferedReader(new FileReader("src/files/temp2.txt")); String foundWord = "dod"; while ((line = reader.readLine()) != null) { String[] words = line.split(","); for (String word : words) { if (word.equals(foundWord)) { name...
android,multidimensional-array,bufferedreader
OK thank you for all your help! I did what CyberGeek.exe suggested but I modified it a bit. Here is my code: public static int[][] tileArray; public static void loadTileMap(String fileName, int height, int width) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(GameMainActivity.assets.open(fileName))); String line; tileArray = new int[width][height];...
You can also use StringBuilder if all you care is to output the indexes. StringBuilder sb = new StringBuilder("array" + xx +" is found at index: "); for (x = 0; x < v; x++) { if (c[x] == xx) { sb.append(x).append(","); } } if (sb.charAt(sb.length() - 1) == ',')...
java,android,sockets,chat,bufferedreader
You're using a BufferedReader and read it with in.readLine(), which, surprise surprise, will return the next line in the response. A line is a string terminated by a newline character, so your BufferedReader will have to wait until it sees a newline until it can return your line. If you...
java,text,split,bufferedreader,stringbuilder
You want to find the lines which match "I n". The regex you need is : ^.I \d$ ^ indicates the beginning of the line. Hence, if there are some whitespaces or text before I, the line will not match the regex. \d indicates any digit. For the sake of...
You can have a pre-defined list of which entries you would like to remove. List<String> entriesToRemove = new ArrayList<String>(); entriesToRemove.add("header"); entriesToRemove.add("end-details"); entriesToRemove.add("end-numberDetails"); if(!entriesToRemove.contains(line)){ //your code to write on a new file }else{ for(String entry: entriesToRemove){ if(line.contains(entry)){ line = line.replace(entry, ""); //your code to write on a new file } }...
android,url,inputstream,bufferedreader
Have a look at URLConnection Also, in the future, avoid using .plist as it something specific to ios and osx. By using another format (like json) you won't have to implement your own parsing....
java,bufferedreader,root-framework
The C++ output statements are without newlines, which will not flush the lines. cout << "ROOT:: loop iteration" << endl; cin >> in_str; cout << "ROOT:: received string " << in_str << endl; The other problem is that the cin never "sees" a line sent from the Java program. You...
java,bufferedreader,bufferedwriter
You need to either flush the buffer post writing the data to buffer like bw.flush(); or close the writer like bw.close();//handle exception if you are not using AutoCloseable feature. ...
java,escaping,bufferedreader,unicode-escapes
You can use a Scanner with a custom delimeter. The delimeter I use is set to match \n but not \u0001\n (where \u0001 represents CTRL+A): try { PrintWriter writer = new PrintWriter("dboutput.txt"); Scanner sc = new Scanner(new File("dbinput.txt")); sc.useDelimiter(Pattern.compile("^(?!.*(\\u0001\\n)).*\\n$")); while (sc.hasNext()) { writer.println(sc.next()); } scanner.close(); writer.close(); } catch (FileNotFoundException e)...
java,file,bufferedreader,bufferedwriter
Be sure you add bw.flush(); to your code after the write to flush the buffer and get the data into the file to be able to read it back....
I see a couple of issues in the code: Inside the second while() loop you are still splitting the string "line", but the while loop assigns the input to "checkLine". You don't reset "exit" to false - this should probably happen after the br.reset(). ...
java,regex,string,substring,bufferedreader
You can use the String#substring(beginIndex) method which would get the substring starting at the specified index until the end of the string: String x = line.substring(line.indexOf("size") + 6); ...
Your best bet might be to recreate the BufferedReader once readLine() returns null. For example: String filename = "[filename]"; BufferedReader reader = new BufferedReader(new FileReader(filename)); while (true) { String line = reader.readLine(); if (line != null) // Use line else { reader.close(); reader = new BufferedReader(new FileReader(filename)); } } This...
java,parsing,input,io,bufferedreader
I think that either you: Normalize your key phrases and names (represent "word\nplus\nword" as "line n has word, line n+1 has plus, line n+2 has word") Process newlines as part of the matching characters (process byte by byte instead of line by line) From your current strategy, option 1 would...
java,android,email,httprequest,bufferedreader
There's an issue with URL encoding. Take a look at This Link String query = URLEncoder.encode("apples oranges", "utf-8"); String url = "http://stackoverflow.com/search?q=" + query; ...
java,android,bufferedreader,randomaccessfile
In order to update the file pointer in a RandomAccessFile you need to use the read() methods that are part of the RandomAccessFile object. Making a separate Reader won't update it. If you need to use BufferedReader you can always wrap a RandomAccessFile in your own InputStream implementation so reads...
java,logic,bufferedreader,bufferedwriter
readLine() can return null, which means end of stream: in this case, end of file. Your code doesn't allow for that possibility, and it also doesn't allow reporting that possibility to the caller when it happens. I would get rid of the readFile() method altogether, and in its place call...
java,android,httprequest,bufferedreader,readline
There is no default method to parse all the html and extract the needed portion. You can save all html in webPage as String and then parse the string to get price out by using code like this: String toFind = "product-card__price\">"; String str1 = webPage.substring(webPage.indexOf(toFind) + toFind.length()); String priceString...
java,file-io,bufferedreader,bufferedwriter
You can write to another file using: outputStream.write(). And when you are done just outputStream.flush() and outputStream.close(). Edit: public void readAndWriteFromfile() throws IOException { BufferedReader inputStream = new BufferedReader(new FileReader( "original.txt")); File UIFile = new File("numbers.txt"); // if File doesnt exists, then create it if (!UIFile.exists()) { UIFile.createNewFile(); } FileWriter...
java,hadoop,bufferedreader,filereader,inputstreamreader
i have found the problem. i have get a checksum exception. now i delete all .crc files from my input file. in this way i get no checksum exception and the buffered reader work fine (uncommented code part, upstairs).
java,inputstream,bufferedreader,fileinputstream
To be able to use reset() in such a way, the whole file must fit into the buffer of the BufferedReader. That means you must either create a BufferedReader with a buffer that is large enough or create a new instance when you want to read the file again....
string,loops,char,bufferedreader
Can you try something like this: String output = ""; while ((line = bufferedReader.readLine()) != null) { output += line; } String parsedOutput = output.split(); You are reading everything into a String and then split it by defining the * to be the separator....
java,bufferedreader,filereader,filewriter,bufferedwriter
When you use FileReader and FileWriter, they will use the default encoding for your platform. That's almost always a bad idea. In your case, it seems that that encoding doesn't support U+0092, which is fairly reasonable given that it's a private use character - many encodings won't support that. I...
java,file,memory,bufferedreader
The BufferedReader effectively takes care of reading the lines in chunks. So really your choice is between: after each call to readLine(), call your method to process it after each call to readLine(), add the line to a list, and then every time the list gets to some size, call...
Try this, StringTokenizer tk = new StringTokenizer(input.readLine()); int m = Integer.parseInt(tk.nextToken()); String s = tk.nextToken(); this is faster than string.split(); ...
java,indexing,guava,bufferedreader,multimap
Why are you calling readLine() inside the while loop? while (((line = br.readLine()) != null)) { line = br.readLine(); When you call readLine() and it is not null, the line would have been read into line variable. Then inside the while loop you are making a second call to readLine()....
java,string,byte,bufferedreader
What you see is the UTF-8 BOM Convert your input file to be without BOM....
java,parsing,bufferedreader,bufferedwriter,replaceall
replaceAll doesn't modify the string you call it on, it returns a new string. Make sure you capture its return value. currentLine = currentLine.replaceAll(" ", "\n"); currentLine = currentLine.replaceAll(";", "\n;"); currentLine = currentLine.replaceAll("\\(", "\n(\n"); currentLine = currentLine.replaceAll("\\)", "\n)\n"); (In fact Strings are immutable, so this is true of all String...
java,tcp,bufferedreader,stack-overflow,message-loop
Don't call run() within run(). This is not a recursive function. If you want to keep reading until some condition, wrap this in a while loop. By calling the method you are executing while you are executing it, you are creating another stack frame. What you really want is just...
java,bufferedreader,inputstreamreader
Seems like your eyes are glancing over a pair of parentheses: while ( (userInput = stdIn.readLine() ) != null) { } I've attempted to make it more clear above. The variable userInput is being assigned stdIn.readLine(). And while userInput isn't null following that assignment, the loop continues. It's just a...
java,file,bufferedreader,filereader,printwriter
For simply writing a small number of strings to a file, I'd recommend using the class "PrintWriter". It wraps itself around a standard Writer and allows you to write any primitive data type and some Objects to a given "Writer" (In our case a FileWriter). This isn't the only way...
Please don't use StringBuffer, these were replaced by StringBuilder ten years ago. don't initialise a StringBuilder with an empty String. This only hurts performance. don't create dummy values for StringBuilders which you discard. don't pass variables via static fields. I suggest you pass it as an argument. Also don't ignore...
So you want to do it using array only. You can consider below example as reference - import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class TitanicApp { int size = 10; int colCount = 6; String[][] array = null; public static void main(String[] args) { TitanicApp app = new TitanicApp();...
java,json,excel,apache-poi,bufferedreader
A small addition to your input reading: String hline; while( (hline = fileReader.readLine()) != null){ line = hline; while( ! hline.endsWith( "}" ) ){ hline = fileReader.readLine(); line += hline; } This should be put into a separate method, but I leave this to you - I don't want to...
java,initialization,bufferedreader,readline
You should create a new Sentence instance only if the english string was found and declare it outside the while loop: Sentence sentenceClass = null; while(line!=null) { // file reading part if (lang.equals("EN")){ sentenceClass = new Sentence(); sentences.add(sentenceClass); sentenceClass.setFraseENG(sentence); } else { sentenceClass.setTranslation(readLine[1]); } line=reader.readLine(); } ...
java,unit-testing,iterator,bufferedreader,factory-pattern
A finally block always executes if there is a try-block before it. So yours always throws a NoSuchElementException(). finally { // return null; throw new NoSuchElementException(); } You should do something in it and not throw an Exception....