Refine search
response.setContentType("application/force-download"); response.setContentLength((int)f.length()); //response.setContentLength(-1); response.setHeader("Content-Transfer-Encoding", "binary"); response.setHeader("Content-Disposition","attachment; filename=\"" + "xxx\"");//fileName); ... ... File f= new File(fileName); InputStream in = new FileInputStream(f); BufferedInputStream bin = new BufferedInputStream(in); DataInputStream din = new DataInputStream(bin); while(din.available() > 0){ out.print(din.readLine()); out.print("\n"); }
System.err.println(ex); return; sock=sockets[i]; if(sock == null) continue; System.out.println("Socket #" + (i + 1) + '=' + sock.getLocalAddress() + ':' + sock.getLocalPort() + ", ttl=" + sock.getTimeToLive() + ", bind interface=" + sock.getInterface()); in=new DataInputStream(System.in); while(true) { System.out.print("> "); line=in.readLine(); if(line.startsWith("quit") || line.startsWith("exit")) System.exit(0); System.err.println(e);
String os = "abc"; System.out.println("---- unicode, big-endian"); for(byte b: os.getBytes("UTF-16BE")) { System.out.println(b); System.out.println("---- ba"); for(byte b: ba) { System.out.println(b); DataInputStream dis = new DataInputStream(bais); System.out.println("---- dis"); String s = dis.readLine(); System.out.println(s); System.out.println("String length is " + s.length()
inStream = new DataInputStream(conn.getInputStream()); String str; while ((str = inStream.readLine()) != null) {
List<Class> classes = getClasses(Test.class.getClassLoader(),"test"); for(Class c:classes){ System.out.println("Class: "+c); URL upackage = cl.getResource(pack); DataInputStream dis = new DataInputStream((InputStream) upackage.getContent()); String line = null; while ((line = dis.readLine()) != null) { if(line.endsWith(".class")) { classes.add(Class.forName(dottedPackage+"."+line.substring(0,line.lastIndexOf('.'))));
inStream = new DataInputStream ( conn.getInputStream() ); String str; while (( str = inStream.readLine()) != null){ Log.e("Debug","Server Response "+str); reponse_data=str;
try { while(true) { DataInputStream is = new DataInputStream(sock.getInputStream()); System.out.println("" +is.readLine()); line =is.readLine(); } // end of while } catch(Exception ex) {} }
public String getStringFromExternalController() { if (DEBUG) System.out.println("getting a string from the external controller"); try { String recievedString = in.readLine(); if (DEBUG) System.out.println(recievedString); return recievedString; } catch (IOException e) { e.printStackTrace(); } return null; }
DataInputStream osRes = new DataInputStream(suProcess.getInputStream()); os.flush(); String currUid = osRes.readLine(); boolean exitSu = false; if (null == currUid)
public static void main( String[] args ) throws Exception { int previousChoice = 0; for( int i = 1; i <= 5; i++ ) { System.out.println("Select an Icecream:\n1.Strawberry\n2.Vanilla\n3.Chocolate\n4.Butterscotch\n5.Black current\n6.Exit"); DataInputStream in = new DataInputStream(System.in); int n = Integer.parseInt(in.readLine()); while (previousChoice == n) { System.out.println("Can't select the same ice-cream twice in a row, try again."); n = Integer.parseInt(in.readLine()); } previousChoice = n; // save previous choice switch( n ) {
InputStream buildinginfo = getResources().openRawResource(R.raw.testbuilding); DataInputStream myDIS = new DataInputStream(buildinginfo); //you've now got an instance of DataInputStream called myDIS String firstString = myDIS.readLine(); //voila ... your firstString variable should contain some text
DataInputStream myStream = new DataInputStream(p.getInputStream()); while ((line = myStream.readLine()) != null) { System.out.println(line); }
@Test public void testCreateFile() throws CatalogException, IOException { String content = "This is the content\tof the file"; try { fileManager.create(studyFqn3, File.Type.FILE, File.Format.UNKNOWN, File.Bioformat.UNKNOWN, "data/test/myTest/myFile.txt", null, null, new File.FileStatus(File.FileStatus.READY), 0, -1, null, -1, null, null, false, "This is the content\tof the file", null, sessionIdUser2); fail("An error should be raised because parents is false"); } catch (CatalogException e) { System.out.println("Correct"); } QueryResult<File> fileQueryResult = fileManager.create(studyFqn3, File.Type.FILE, File.Format.UNKNOWN, File.Bioformat.UNKNOWN, "data/test/myTest/myFile.txt", null, null, new File.FileStatus(File.FileStatus.READY), 0, -1, null, -1, null, null, true, content, null, sessionIdUser2); CatalogIOManager ioManager = catalogManager.getCatalogIOManagerFactory().get(fileQueryResult.first().getUri()); assertTrue(ioManager.exists(fileQueryResult.first().getUri())); DataInputStream fileObject = ioManager.getFileObject(fileQueryResult.first().getUri(), -1, -1); assertEquals(content, fileObject.readLine()); }
/** * See the general contract of the {@code readLine} * method of {@code DataInput}. * <p> * Bytes for this operation are read from the contained input stream. * * @deprecated This method does not properly convert bytes to characters. * * @return the next line of text from this input stream. * @exception IOException if an I/O error occurs. * @see java.io.BufferedReader#readLine() * @see java.io.DataInputStream#readLine() * @noinspection deprecation */ public String readLine() throws IOException { DataInputStream ds = new DataInputStream(in); return ds.readLine(); } }
try { // Get input from the client DataInputStream in = new DataInputStream (server.getInputStream()); PrintStream out = new PrintStream(server.getOutputStream()); out.println("You have connected to the server."); out.println("Welcome."); in.readLine(); //consume first two bytes //the rest of your code...
FileInputStream fis; final StringBuffer storedString = new StringBuffer(); try { fis = openFileInput("out.txt"); DataInputStream dataIO = new DataInputStream(fis); String strLine = null; if ((strLine = dataIO.readLine()) != null) { storedString.append(strLine); } dataIO.close(); fis.close(); } catch (Exception e) { }