You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							35 lines
						
					
					
						
							947 B
						
					
					
				
			
		
		
	
	
							35 lines
						
					
					
						
							947 B
						
					
					
				| /*
 | |
|  * Copyright (c) 2017-present, Facebook, Inc.
 | |
|  *
 | |
|  * This source code is licensed under the MIT license found in the
 | |
|  * LICENSE file in the root directory of this source tree.
 | |
|  */
 | |
| 
 | |
| package codetoanalyze.java.checkers;
 | |
| 
 | |
| import java.io.FileInputStream;
 | |
| import java.io.FileNotFoundException;
 | |
| import java.io.IOException;
 | |
| 
 | |
| public class LeaksLoop {
 | |
| 
 | |
|   void openCloseLoopOk(String[] files) throws IOException, FileNotFoundException {
 | |
|     FileInputStream stream;
 | |
|     for (int i = 0; i < files.length; i++) {
 | |
|       String file = files[i];
 | |
|       stream = new FileInputStream(file);
 | |
|       stream.close();
 | |
|     }
 | |
|   }
 | |
| 
 | |
|   void openAllCloseAllLoopOk(String[] files) throws IOException, FileNotFoundException {
 | |
|     FileInputStream[] streams = new FileInputStream[files.length];
 | |
|     for (int i = 0; i < files.length; i++) {
 | |
|       streams[i] = new FileInputStream(files[i]);
 | |
|     }
 | |
|     for (int i = 0; i < files.length; i++) {
 | |
|       streams[i].close();
 | |
|     }
 | |
|   }
 | |
| }
 |